Which of the 2 APIs is simpler to read/write/edit excel sheets ? Do these APIs not support CSV extensions ?
这两个api中哪个更容易读/写/编辑excel表?这些api不支持CSV扩展吗?
Using JXL for file.xls and file.xlsx, I get an exception like:
使用JXL文件。xls和文件。xlsx,我有一个例外:
jxl.read.biff.BiffException: Unable to recognize OLE stream
at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
at jxl.read.biff.File.<init>(File.java:127)
at jxl.Workbook.getWorkbook(Workbook.java:268)
at core.ReadXLSheet.contentReading(ReadXLSheet.java:46)
at core.ReadXLSheet.init(ReadXLSheet.java:22)
at core.ReadXLSheet.main(ReadXLSheet.java:72)
Both for .xls and .xlsx extensions. Java Version I am using is : JDK1.6
同时适用于.xls和.xlsx扩展。我正在使用的Java版本是:JDK1.6
4 个解决方案
#1
230
I have used both JXL (now "JExcel") and Apache POI. At first I used JXL, but now I use Apache POI.
我使用了JXL(现在的“JExcel”)和Apache POI。起初我使用JXL,但现在我使用Apache POI。
First, here are the things where both APIs have the same end functionality:
首先,这两个api都具有相同的最终功能:
- Both are free
- 都是免费的
- Cell styling: alignment, backgrounds (colors and patterns), borders (types and colors), font support (font names, colors, size, bold, italic, strikeout, underline)
- 单元样式:对齐、背景(颜色和模式)、边框(类型和颜色)、字体支持(字体名称、颜色、大小、粗体、斜体、删除线、下划线)
- Formulas
- 公式
- Hyperlinks
- 超链接
- Merged cell regions
- 合并后的单元格区域
- Size of rows and columns
- 行和列的大小
- Data formatting: Numbers and Dates
- 数据格式:数字和日期。
- Text wrapping within cells
- 文本包装细胞内
- Freeze Panes
- 冻结窗格
- Header/Footer support
- 页眉/页脚的支持
- Read/Write existing and new spreadsheets
- 读/写现有的和新的电子表格
- Both attempt to keep existing objects in spreadsheets they read in intact as far as possible.
- 这两种方法都试图将现有的对象保存在尽可能完整的电子表格中。
However, there are many differences:
然而,有许多不同之处:
- Perhaps the most significant difference is that Java JXL does not support the Excel 2007+ ".xlsx" format; it only supports the old BIFF (binary) ".xls" format. Apache POI supports both with a common design.
- 也许最重要的区别是Java JXL不支持Excel 2007+。xlsx”格式;它只支持旧的BIFF(二进制)”。xls”格式。Apache POI支持使用公共设计。
- Additionally, the Java portion of the JXL API was last updated in 2009 (3 years, 4 months ago as I write this), although it looks like there is a C# API. Apache POI is actively maintained.
- 此外,JXL API的Java部分最近一次更新是在2009年(3年,4个月前我写这篇文章时),尽管看起来有一个c# API。积极维护Apache POI。
- JXL doesn't support Conditional Formatting, Apache POI does, although this is not that significant, because you can conditionally format cells with your own code.
- JXL不支持条件格式,Apache POI支持,尽管这并不重要,因为您可以用自己的代码有条件地格式化单元格。
- JXL doesn't support rich text formatting, i.e. different formatting within a text string; Apache POI does support it.
- JXL不支持富文本格式,即文本字符串中的不同格式;Apache POI确实支持它。
- JXL only supports certain text rotations: horizontal/vertical, +/- 45 degrees, and stacked; Apache POI supports any integer number of degrees plus stacked.
- JXL只支持某些文本旋转:水平/垂直、+/- 45度和叠加;Apache POI支持任意数量的角度加上叠加。
- JXL doesn't support drawing shapes; Apache POI does.
- JXL不支持绘制图形;Apache POI。
- JXL supports most Page Setup settings such as Landscape/Portrait, Margins, Paper size, and Zoom. Apache POI supports all of that plus Repeating Rows and Columns.
- JXL支持大多数页面设置,比如横向/纵向、页边距、纸张大小和缩放。Apache POI支持所有这些,并支持重复的行和列。
- JXL doesn't support Split Panes; Apache POI does.
- JXL不支持分割窗格;Apache POI。
- JXL doesn't support Chart creation or manipulation; that support isn't there yet in Apache POI, but an API is slowly starting to form.
- JXL不支持图表创建或操作;在Apache POI中还没有这种支持,但是一个API正在慢慢地开始形成。
- Apache POI has a more extensive set of documentation and examples available than JXL.
- Apache POI有比JXL更广泛的文档和示例集。
Additionally, POI contains not just the main "usermodel" API, but also an event-based API if all you want to do is read the spreadsheet content.
此外,POI不仅包含主要的“usermodel”API,还包含一个基于事件的API(如果您只想读取电子表格内容的话)。
In conclusion, because of the better documentation, more features, active development, and Excel 2007+ format support, I use Apache POI.
总之,由于有更好的文档、更多的特性、主动开发和Excel 2007+格式支持,我使用了Apache POI。
#2
11
I have used POI.
我用芋泥。
If you use that, keep on eye those cell formatters: create one and use it several times instead of creating each time for cell, it isa huge memory consumption difference or large data.
如果您使用它,请注意这些单元格格式:创建一个并多次使用它,而不是每次都为单元格创建,这是巨大的内存消耗差异或大数据。
#3
5
I am not familiar with JXL and but we use POI. POI is well maintained and can handle both the binary .xls format and the new xml based format that was introduced in Office 2007.
我不熟悉JXL,但是我们使用POI。POI维护良好,可以同时处理二进制.xls格式和在office2007中引入的新的基于xml的格式。
CSV files are not excel files, they are text based files, so these libraries don't read them. You will need to parse out a CSV file yourself. I am not aware of any CSV file libraries, but I haven't looked either.
CSV文件不是excel文件,它们是基于文本的文件,所以这些库不会读取它们。您需要自己解析CSV文件。我不知道任何CSV文件库,但我也没有查看。
#4
1
For reading "plain" CSV files in Java, there is a library called OpenCSV, available here: http://opencsv.sourceforge.net/
对于在Java中读取“普通”CSV文件,有一个名为OpenCSV的库,可以在这里找到:http://opencsv.sourceforge.net/
#1
230
I have used both JXL (now "JExcel") and Apache POI. At first I used JXL, but now I use Apache POI.
我使用了JXL(现在的“JExcel”)和Apache POI。起初我使用JXL,但现在我使用Apache POI。
First, here are the things where both APIs have the same end functionality:
首先,这两个api都具有相同的最终功能:
- Both are free
- 都是免费的
- Cell styling: alignment, backgrounds (colors and patterns), borders (types and colors), font support (font names, colors, size, bold, italic, strikeout, underline)
- 单元样式:对齐、背景(颜色和模式)、边框(类型和颜色)、字体支持(字体名称、颜色、大小、粗体、斜体、删除线、下划线)
- Formulas
- 公式
- Hyperlinks
- 超链接
- Merged cell regions
- 合并后的单元格区域
- Size of rows and columns
- 行和列的大小
- Data formatting: Numbers and Dates
- 数据格式:数字和日期。
- Text wrapping within cells
- 文本包装细胞内
- Freeze Panes
- 冻结窗格
- Header/Footer support
- 页眉/页脚的支持
- Read/Write existing and new spreadsheets
- 读/写现有的和新的电子表格
- Both attempt to keep existing objects in spreadsheets they read in intact as far as possible.
- 这两种方法都试图将现有的对象保存在尽可能完整的电子表格中。
However, there are many differences:
然而,有许多不同之处:
- Perhaps the most significant difference is that Java JXL does not support the Excel 2007+ ".xlsx" format; it only supports the old BIFF (binary) ".xls" format. Apache POI supports both with a common design.
- 也许最重要的区别是Java JXL不支持Excel 2007+。xlsx”格式;它只支持旧的BIFF(二进制)”。xls”格式。Apache POI支持使用公共设计。
- Additionally, the Java portion of the JXL API was last updated in 2009 (3 years, 4 months ago as I write this), although it looks like there is a C# API. Apache POI is actively maintained.
- 此外,JXL API的Java部分最近一次更新是在2009年(3年,4个月前我写这篇文章时),尽管看起来有一个c# API。积极维护Apache POI。
- JXL doesn't support Conditional Formatting, Apache POI does, although this is not that significant, because you can conditionally format cells with your own code.
- JXL不支持条件格式,Apache POI支持,尽管这并不重要,因为您可以用自己的代码有条件地格式化单元格。
- JXL doesn't support rich text formatting, i.e. different formatting within a text string; Apache POI does support it.
- JXL不支持富文本格式,即文本字符串中的不同格式;Apache POI确实支持它。
- JXL only supports certain text rotations: horizontal/vertical, +/- 45 degrees, and stacked; Apache POI supports any integer number of degrees plus stacked.
- JXL只支持某些文本旋转:水平/垂直、+/- 45度和叠加;Apache POI支持任意数量的角度加上叠加。
- JXL doesn't support drawing shapes; Apache POI does.
- JXL不支持绘制图形;Apache POI。
- JXL supports most Page Setup settings such as Landscape/Portrait, Margins, Paper size, and Zoom. Apache POI supports all of that plus Repeating Rows and Columns.
- JXL支持大多数页面设置,比如横向/纵向、页边距、纸张大小和缩放。Apache POI支持所有这些,并支持重复的行和列。
- JXL doesn't support Split Panes; Apache POI does.
- JXL不支持分割窗格;Apache POI。
- JXL doesn't support Chart creation or manipulation; that support isn't there yet in Apache POI, but an API is slowly starting to form.
- JXL不支持图表创建或操作;在Apache POI中还没有这种支持,但是一个API正在慢慢地开始形成。
- Apache POI has a more extensive set of documentation and examples available than JXL.
- Apache POI有比JXL更广泛的文档和示例集。
Additionally, POI contains not just the main "usermodel" API, but also an event-based API if all you want to do is read the spreadsheet content.
此外,POI不仅包含主要的“usermodel”API,还包含一个基于事件的API(如果您只想读取电子表格内容的话)。
In conclusion, because of the better documentation, more features, active development, and Excel 2007+ format support, I use Apache POI.
总之,由于有更好的文档、更多的特性、主动开发和Excel 2007+格式支持,我使用了Apache POI。
#2
11
I have used POI.
我用芋泥。
If you use that, keep on eye those cell formatters: create one and use it several times instead of creating each time for cell, it isa huge memory consumption difference or large data.
如果您使用它,请注意这些单元格格式:创建一个并多次使用它,而不是每次都为单元格创建,这是巨大的内存消耗差异或大数据。
#3
5
I am not familiar with JXL and but we use POI. POI is well maintained and can handle both the binary .xls format and the new xml based format that was introduced in Office 2007.
我不熟悉JXL,但是我们使用POI。POI维护良好,可以同时处理二进制.xls格式和在office2007中引入的新的基于xml的格式。
CSV files are not excel files, they are text based files, so these libraries don't read them. You will need to parse out a CSV file yourself. I am not aware of any CSV file libraries, but I haven't looked either.
CSV文件不是excel文件,它们是基于文本的文件,所以这些库不会读取它们。您需要自己解析CSV文件。我不知道任何CSV文件库,但我也没有查看。
#4
1
For reading "plain" CSV files in Java, there is a library called OpenCSV, available here: http://opencsv.sourceforge.net/
对于在Java中读取“普通”CSV文件,有一个名为OpenCSV的库,可以在这里找到:http://opencsv.sourceforge.net/