问题
It is to my understanding that EPPlus loads the entire Excel file into memory which is creating a performance hit. I was wondering if there is a way to partially load Excel into EPPlus to read a small range of rows? I'm using EPPlus version 4.0.4.
For instance, I can open a CSV file and read just a small range of rows/lines and performance is good. The CSV file could contain way more then a million rows/lines.
IEnumerable<string> lines = System.IO.File.ReadLines(filePath).Skip(0).Take(20).ToList();
回答1:
I don't think that will be possible.
CSV files are just plain text files. That means you can seek and read whatever point in the file you want to.
Excel files (.xlsx) are really just ZIP files, the data contained within is various XML files that describe the contents. So since it's compressed, you can't really partially load the file.
If you want to see what's in a .xlsx file, just change the extension on it to .zip, then use your favorite extraction tool to look at the contents.
来源:https://stackoverflow.com/questions/32743720/partial-load-excel-epplus-c-sharp