MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

多Sheet XLSX文件,MiniExcel读取数据时间过长

Open chenzanyu opened this issue 1 year ago • 3 comments

Excel Type

  • [✔ ] XLSX
  • [ ] XLSM
  • [ ] CSV
  • [ ] OTHER

Upload Excel File

Please attach your issue file by dragging or droppng, selecting or pasting them.

MiniExcel Version

Description

chenzanyu avatar May 27 '24 17:05 chenzanyu

这个Excel文件,如果修改每个sheet的title公司名称,读取可以在2秒以内完成,原文件需要>40秒才能成功读取

chenzanyu avatar May 27 '24 18:05 chenzanyu

下面是读取XLSX文件代码

OpenXmlConfiguration configuration = new OpenXmlConfiguration() { FillMergedCells = true };
var source_Rows = MiniExcel.Query(stream, configuration: configuration).ToList();

chenzanyu avatar May 27 '24 18:05 chenzanyu

Ok so actually this is happening because your excel file is malformed, sort of. It turns out that even though all columns past N are empty, for some reason the worksheet's horizontal dimension is maxed out, maybe because of the background color of the cells. This means that you were trying to query 15k+ columns, that's why it was taking so long. We might add the option for an upper bound in the future, but for the time being you can use MiniExcel.QueryRange or just copy the data in a clean sheet and query from there.

michelebastione avatar May 31 '25 22:05 michelebastione