From c387222d1fcf9c4fa124a10335ca7dbf3f2338e0 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Fri, 8 Nov 2024 15:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=97=A5=E6=9C=9F=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=B1=BB=E5=9E=8B=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `ExportModel.cs` 文件中: - 添加了 `MiniExcelLibs.Attributes` 和 `System` 的引用。 - 将 `OrderDate` 和 `DeliveryDate` 属性的数据类型从 `string` 改为 `DateTime`,并添加了 `ExcelColumn` 属性以指定日期格式为 "MM月dd日"。 在 `MainViewModel.cs` 文件中: - 修改了 `data.Model` 的格式字符串,将 "1x" 改为 "1×"。 - 将 `nowDateStr` 和 `nowDeliveryDateStr` 的初始化从字符串格式的日期改为 `DateTime` 类型,并注释掉了 `.ToString("yyyy-MM-dd")` 部分。 --- Sinvo.EplanHpD.Plugin.WPFUI/Models/ExportModel.cs | 11 ++++++++--- .../ViewModel/MainViewModel.cs | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExportModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExportModel.cs index 1427eef..eb1d7af 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExportModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExportModel.cs @@ -1,4 +1,7 @@ -namespace Sinvo.EplanHpD.Plugin.WPFUI.Models +using MiniExcelLibs.Attributes; +using System; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Models { public class ExportModel { @@ -143,12 +146,14 @@ /// /// 下单日期 /// - public string OrderDate { get; set; } + [ExcelColumn(Format = "MM月dd日")] + public DateTime OrderDate { get; set; } /// /// 交货日期 /// - public string DeliveryDate { get; set; } + [ExcelColumn(Format = "MM月dd日")] + public DateTime DeliveryDate { get; set; } /// /// 是否忽略异常 diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs index 50339a3..71e5b16 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs @@ -288,7 +288,7 @@ public partial class MainViewModel : INotifyPropertyChanged //data.WireNumber = item.Imprint; data.Quantity = 1; //"RV-"&A2&"-"&"1×"&J2&"-"&L2&"-"&"16×N2"&"-"&M2 - data.Model = $"RV-{data.WireColor}-1x{data.CrossSection}-{data.WireLength}-16×N2-{data.WireNumber}"; + data.Model = $"RV-{data.WireColor}-1×{data.CrossSection}-{data.WireLength}-16×N2-{data.WireNumber}"; //data.IsChecked = true; if (!string.IsNullOrEmpty(data.DiscolorationDesc)) { @@ -483,8 +483,8 @@ public partial class MainViewModel : INotifyPropertyChanged ExportData = []; int seqNo = 1; var dataList = new List(); - var nowDateStr = DateTime.Now.ToString("yyyy-MM-dd"); - var nowDeliveryDateStr = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd"); + var nowDateStr = DateTime.Now;//.ToString("yyyy-MM-dd"); + var nowDeliveryDateStr = DateTime.Now.AddDays(7);//.ToString("yyyy-MM-dd"); //foreach (var stuffedDataModel in StuffedData) StuffedData.AsParallel().WithDegreeOfParallelism(1).ForAll(stuffedDataModel => {