-
-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
导出数据的数据头没有汉化 #53
Comments
请提供下完整的Demo(包含Excel文件)。谢谢。 |
TestMagicIE.zip |
导出的代码很简单:
得到两个excel表,其中一个salarytemplate.xlsx表头汉化了,newSalary.xlsx没有汉化。
用注释的那行代码取不到数据,因为导出的数据的类型是Salary类,但如果用Salary做为导入数据源,SalaryDate没有正确识别。 |
看了下,这个不是Bug。因为导入导出的Dto使用的同一个,您只设置了导入的Header特性,并没有设置导出的Header特性。所以导出的Excel表头使用是的属性名称。 |
谢谢,还有个问题,导入的SalaryDate没有数据,请问还要怎么设置。我增加了:
还是不起作用 |
@zsanhong 方便将结果截图么? |
@zsanhong 见我们的单元测试:ExcelExporter_Tests 的AttrsExport_Test,相关验证逻辑一直是通过的: [Fact(DisplayName = "DTO特性导出(测试格式化)")]
public async Task AttrsExport_Test()
{
IExporter exporter = new ExcelExporter();
var filePath = GetTestFilePath($"{nameof(AttrsExport_Test)}.xlsx");
DeleteFile(filePath);
var data = GenFu.GenFu.ListOf<ExportTestDataWithAttrs>(100);
foreach (var item in data)
{
item.LongNo = 45875266524;
}
var result = await exporter.Export(filePath, data);
result.ShouldNotBeNull();
File.Exists(filePath).ShouldBeTrue();
using (var pck = new ExcelPackage(new FileInfo(filePath)))
{
pck.Workbook.Worksheets.Count.ShouldBe(1);
var sheet = pck.Workbook.Worksheets.First();
sheet.Cells[sheet.Dimension.Address].Rows.ShouldBe(101);
sheet.Cells["A2"].Text.ShouldBe(data[0].Text);
//[ExporterHeader(DisplayName = "日期1", Format = "yyyy-MM-dd")]
sheet.Cells["E2"].Text.Equals(DateTime.Parse(sheet.Cells["E2"].Text).ToString("yyyy-MM-dd"));
//[ExporterHeader(DisplayName = "日期2", Format = "yyyy-MM-dd HH:mm:ss")]
sheet.Cells["F2"].Text.Equals(DateTime.Parse(sheet.Cells["F2"].Text).ToString("yyyy-MM-dd HH:mm:ss"));
//默认DateTime
sheet.Cells["G2"].Text.Equals(DateTime.Parse(sheet.Cells["G2"].Text).ToString("yyyy-MM-dd"));
}
} |
麻烦看看我上传的例子为什么导入时取不到SalaryDate的值 |
@zsanhong 已确认日期导入这里存在一个Bug,稍后我们会修复并发布一个版本。 |
@zsanhong 该问题已在develop分支修复,对应单元测试为 ExportAndImportUseOneDto_Test 。明天我们将会基于成功的构建进行发包。非常感谢! |
感谢你们的杰出工作,顺便说一下,我也在长沙,有机会向你们学习! |
@zsanhong |
这样到出模板数据头汉化了
但是如果导出的数据,excel数据头没有汉化
其中 dtos是ImportMonthSalaryDto的集合

The text was updated successfully, but these errors were encountered: