部分加载Excel EPPlus C# [英] Partial Load Excel EPPlus C#

查看:253
本文介绍了部分加载Excel EPPlus C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,EPPlus将整个Excel文件加载到内存中,这会产生性能问题。
我想知道是否可以将Excel部分加载到EPPlus中以读取少量行?我使用的是EPPlus 4.0.4版。



例如,我可以打开CSV文件并仅读取一小部分行/行,并且性能很好。 CSV文件可能包含的行数超过一百万行。

  IEnumerable< string>行= System.IO.File.ReadLines(filePath).Skip(0).Take(20).ToList(); 


解决方案

我认为这不可能。 / p>

CSV文件只是纯文本文件。这意味着您可以查找和读取文件中的任意点。



Excel文件(.xlsx)实际上只是ZIP文件,其中包含的数据是各种XML描述内容的文件。因此,由于已压缩,因此您无法真正部分加载文件。



如果您想查看.xlsx文件中的内容,只需将其扩展名更改为即可。 zip,然后使用您喜欢的提取工具查看内容。


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();

解决方案

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.

这篇关于部分加载Excel EPPlus C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆