问题描述
我需要阅读XLSX档案,并从中提取内容的最大数量。我应该使用哪种API的吗?
I need to read XLSX files and extract a maximum amount of content from it. Which of the API's should I use?
OLE DB,开放的XML SDK或Excel互操作?
OLE DB, open XML SDK, or Excel Interop?
- 这是最容易使用?
- 您可检索使用一种或另一种的所有信息?也就是说,日期,时间,合并单元格,表格,数据透视表等。
推荐答案
可以尝试所有这些,选择适合一个你最...
You can try all of them and choose the one that fits you most...
根据你想阅读,我建议您通过互操作或使用Open XML数据OLE DB。结果
我不知道一个开放的XML SDK,尽管我与库的一些经验其中我使用了很多,可以说只好话 - 它的快速,简单易学,具有很好的例子。图书馆是立足于开放式的Office XML格式的,所以我想这几乎是一样的,你所提到的SDK,并能够轻松读写Excel 2007和2010文件。结果
在链接网页,你会发现一个库本身,文档和一些例如Hello World的项目进行下载。
Depending on data you want to read, I'd suggest you to use Open XML over Interop or Ole DB.
I don't know an open XML SDK, although I've some experience with EPPlus library which I'm using a lot and can say only good words about it - it's fast, easy to learn, with good examples. The library is basing on Open Office XML format, so I suppose it's pretty much the same as the SDK you've mentioned, and is capable of easy read and write Excel 2007 and 2010 files.
On the linked web, you'll find a library itself, documentation and some example "Hello World" projects to download.
为什么要摆在首位的图书馆吗?因为有了它,你将能够读取,不仅单元格的值,而且他们的颜色,字体,宽度和高度,合并,所有的东西细节,你不仅可以阅读,但修改为好。更重要的是,你不需要安装Excel来做到这一点。
Why that library in the first place? Because with it you will be able to read not only cells values, but also their colors, fonts, widths and heights, merging and all that detailed stuff, that you can not only read, but modify as well. What's more, you don't need the Excel installed to do that.
在第二位 - 万一你需要从工作表中提取的表格数据 - 你可能与OLE DB玩。恐怕与你将无法提取有关格式,颜色等任何信息,以及数据必须以表格的工作安排,所以你可以把作为一个数据库的表中。
On the second place - just in case you need to extract tabular data from worksheet - you may play with OLE DB. I'm afraid with that you won't be able to extract any info about formats, colors etc., as well as the data must be in a tabular organized worksheet, so you can treat is as a database's table.
最后一个是互操作,这是因为:结果
- 这是一个COM库,所以你需要通过.NET用它玩的时候非常小心,因为它很容易引起一些人的丑陋,很难找到内存泄漏(由我自己不愉快的经历证实) - 如果不妥善处理他们的对象,它离开EXCEL.EXE进程打开的,结果
- 这是基本上,它几乎没有更多的附加值以前的方法(EPPlus或OLEDB)之一,需要Excel要安装客户端的计算机上,那么为什么要使用它 - 比以前的方法,结果
很慢?
The last one is Interop, because:
- it's a COM library, so you need to be very careful when playing with it via .NET, as it's easy to cause some ugly and hard to find memory leaks (confirmed by myself bad experience) - if you don't dispose their objects properly, it leaves the Excel.exe process opened,
- it's much slower than previous methods,
- basically, it has almost no more added value that one of the previous methods (EPPlus or OleDB) and requires Excel to be installed on client's machine, so why to use it?
好运气,然后。
这篇关于OLE DB VS开放XML SDK VS Excel.interop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!