Magicodes.IE
Magicodes.IE copied to clipboard
使用导入数据时候,如果有空行,导出的错误提示文件信息就会出现提示错误,但是指向的导入错误顺序乱了
使用导入例子代码: IExcelImporter Importer = new ExcelImporter(); var filePath = Path.Combine(Directory.GetCurrentDirectory(), "缴费流水导入模板1.xlsx"); var import = await Importer.Import<Import_Pid_Wlxqmx>(filePath); import.ShouldNotBeNull(); import.HasError.ShouldBeTrue(); import.Exception.ShouldBeNull(); import.Data.Count.ShouldBe(import.Data.Count);
非常感谢。 导入默认会自动跳过空行,导入错误顺序错乱的问题我们跟进下。
导入默认会自动跳过空行
@xin-lai
版本2.4
为什么导入20W+的数据,已设置[ExcelImporter(MaxCount = int.MaxValue)]
却提示最大允许导入条数不能超过2147483647条!
是因为数据后面还有数不清的空行么?
@zfmy @hueifeng 这个我们测试一下。
@xin-lai I found this in source https://github.com/dotnetcore/Magicodes.IE/blob/1529bf08c785018a8bd5e85e409c498e8b3b9bd9/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs#L971
After checking my excel file, I found that sometimes Dimension.End
property could contain empty rows, which lead to this bug.
And I try to copy only data rows to a new sheet, the exception goes away. Just for anyone who had this problem.
OK, we will keep following up, thank you very much! Can you upload your demo source code?
Just use this excel file, you will see. Test.xlsx
收到,正在编写相关单元测试。
这个是超过值范围了,我们将考虑增加限制。 int.MaxValue+1=int.MinValue=-2147483648
@xin-lai 关键是有内容的行数只有4,但是 Dimension.End.Row 获取的是却是一个很大的值,所以这里使用Dimension.End.Row 作为表格实际行数是否合适?
Dimension.End.Row获取的是实际的行数。@RayMMond
如果实际行数 != 有数据的行数怎么办? 相当于检查用的实际行数,但是导入却会忽略空行 https://github.com/dotnetcore/Magicodes.IE/blob/1529bf08c785018a8bd5e85e409c498e8b3b9bd9/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs#L981-L982
如果实际行数1000000,只有第一行有数据,剩下的都是空行,那么还使用实际行数(Dimension.End.Row)作为检查导入行数限制是否合适? @xin-lai