Magicodes.IE icon indicating copy to clipboard operation
Magicodes.IE copied to clipboard

使用导入数据时候,如果有空行,导出的错误提示文件信息就会出现提示错误,但是指向的导入错误顺序乱了

Open xunmengyuansnow opened this issue 4 years ago • 11 comments

QQ截图20201109105147

使用导入例子代码: 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);

xunmengyuansnow avatar Nov 09 '20 02:11 xunmengyuansnow

非常感谢。 导入默认会自动跳过空行,导入错误顺序错乱的问题我们跟进下。

xin-lai avatar Nov 09 '20 02:11 xin-lai

导入默认会自动跳过空行

@xin-lai 版本2.4 为什么导入20W+的数据,已设置[ExcelImporter(MaxCount = int.MaxValue)] 却提示最大允许导入条数不能超过2147483647条!

是因为数据后面还有数不清的空行么?

zfmy avatar Nov 13 '20 03:11 zfmy

@zfmy @hueifeng 这个我们测试一下。

xin-lai avatar Nov 16 '20 09:11 xin-lai

@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.

RayMMond avatar Nov 17 '20 05:11 RayMMond

OK, we will keep following up, thank you very much! Can you upload your demo source code?

xin-lai avatar Nov 17 '20 07:11 xin-lai

Just use this excel file, you will see. Test.xlsx

RayMMond avatar Nov 17 '20 09:11 RayMMond

收到,正在编写相关单元测试。

xin-lai avatar Nov 18 '20 05:11 xin-lai

这个是超过值范围了,我们将考虑增加限制。 int.MaxValue+1=int.MinValue=-2147483648

xin-lai avatar Nov 18 '20 05:11 xin-lai

@xin-lai 关键是有内容的行数只有4,但是 Dimension.End.Row 获取的是却是一个很大的值,所以这里使用Dimension.End.Row 作为表格实际行数是否合适?

RayMMond avatar Nov 19 '20 04:11 RayMMond

Dimension.End.Row获取的是实际的行数。@RayMMond

xin-lai avatar Nov 19 '20 14:11 xin-lai

如果实际行数 != 有数据的行数怎么办? 相当于检查用的实际行数,但是导入却会忽略空行 https://github.com/dotnetcore/Magicodes.IE/blob/1529bf08c785018a8bd5e85e409c498e8b3b9bd9/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs#L981-L982

如果实际行数1000000,只有第一行有数据,剩下的都是空行,那么还使用实际行数(Dimension.End.Row)作为检查导入行数限制是否合适? @xin-lai

RayMMond avatar Nov 20 '20 01:11 RayMMond