https://poi.apache.org/components/spreadsheet/index.html(翻译1)
Posted bluss-yang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了https://poi.apache.org/components/spreadsheet/index.html(翻译1)相关的知识,希望对你有一定的参考价值。
POI-HSSF and POI-XSSF/SXSSF - Java API To Access Microsoft Excel Format Files
Overview
Overview
HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
HSSF是java对97-07版excel的实现,XSSF是对2007版(.xlsx)格式的实现
HSSF and XSSF provides ways to read spreadsheets create, modify, read and write XLS spreadsheets. They provide:
- low level structures for those with special needs
- an eventmodel api for efficient read-only access
- a full usermodel api for creating, reading and modifying XLS files
HSSF和XSSF提供对电子表格创建,修改,读取,写入的方式,他们提供如下:
- 低级别架构为有特殊需要的人
- 一个高效的eventmodel api 只读访问
- 一个完整的usermodel api 对于xls文件的创建,修改,读取
For people converting from pure HSSF usermodel, who wish to use the joint SS Usermodel for HSSF and XSSF support, then see the ss usermodel converting guide.
对于从纯HSSF 用户模式转换过来的用户,希望使用 联合ss对hssf,xssf支持,需要去看ss usermodel converting guide.
An alternate way of generating a spreadsheet is via the Cocoon serializer (yet you'll still be using HSSF indirectly). With Cocoon you can serialize any XML datasource (which might be a ESQL page outputting in SQL for instance) by simply applying the stylesheet and designating the serializer.
另一种生成电子表格的替换方法是通过COcoon序列化器(但是你仍要间接的使用HSSF),使用Cocon你可以序列化任何XML数据源(例如,哪个可能是用SQL输出的ESQL页面)通过简单应用样式和指定序列化方式
If you're merely reading spreadsheet data, then use the eventmodel api in either the org.apache.poi.hssf.eventusermodel package, or the org.apache.poi.xssf.eventusermodel package, depending on your file format.
如果你只是读取电子表格的数据,使用 org.apache.poi.hssf.eventusermodel package, or the org.apache.poi.xssf.eventusermode eventmodel api ,取决于你的文件类型。
If you're modifying spreadsheet data then use the usermodel api. You can also generate spreadsheets this way.
如果你想修改电子表格就需要使用usermodel api ,你也可以使用它创建电子表格
Note that the usermodel system has a higher memory footprint than the low level eventusermodel, but has the major advantage of being much simpler to work with. Also please be aware that as the new XSSF supported Excel 2007 OOXML (.xlsx) files are XML based, the memory footprint for processing them is higher than for the older HSSF supported (.xls) binary files.
注意usermodel系统比低级别的eventusermodel拥有更高的内存占用率,但是主要的优势是使用简单。还有应该注意新的XSSF支持基于XML构建的007excel,但是内存占有率高于老版本的HSSF的二进制文件
SXSSF (Since POI 3.8 beta3)SSF (Since POI 3.8 beta3)
Since 3.8-beta3, POI provides a low-memory footprint SXSSF API built on top of XSSF.
自从3.8版本后,POI提供了一个低内存占用率的SXXF构建于XSSF之上
SXSSF is an API-compatible streaming extension of XSSF to be used when very large spreadsheets have to be produced, and heap space is limited. SXSSF achieves its low memory footprint by limiting access to the rows that are within a sliding window, while XSSF gives access to all rows in the document. Older rows that are no longer in the window become inaccessible, as they are written to the disk.
SXXF 是一个对一XSSF 的API兼容性的流扩展,用于大的电子表格产生,并且在空间有限的情况下。SXXF实现它的低内存占用率是通过限制访问行数在一个滑动窗内。然而XSSF允许访问所有行,不再位于窗口中的旧行在写入磁盘时变得不可访问。
In auto-flush mode the size of the access window can be specified, to hold a certain number of rows in memory. When that value is reached, the creation of an additional row causes the row with the lowest index to to be removed from the access window and written to disk. Or, the window size can be set to grow dynamically; it can be trimmed periodically by an explicit call to flushRows(int keepRows) as needed.
自动刷新模式下可以指定访问窗口的大小,在内存中保存一定数量的行,当达到设定的值的时候。创建附加行会导致索引最低的行从访问窗口中删除并写入磁盘,或者,可以将窗口大小设置为动态增长,它可以根据需要通过显式调用flushRows(int keepRows)周期性地进行修剪。
Due to the streaming nature of the implementation, there are the following limitations when compared to XSSF:
- Only a limited number of rows are accessible at a point in time.
- Sheet.clone() is not supported.
- Formula evaluation is not supported
由于实现的流媒体特性,与XSSF相比存在以下限制:
- 在某个时间只能访问限制的行数
- 不支持sheet的克隆
- 不支持公式计算
See more details at SXSSF How-To
The table below synopsizes the comparative features of POI's Spreadsheet API:
下面的表格对POI API比较特性做了概述
Spreadsheet API Feature Summary
HSSF(.xls) | XSSF(.xlsx) | ||||
eventmodel | usermodel | eventmodel | usermodel | SXXF | |
APIType | Streaming(ala SAX) | In memory tree(ala DOM) | Streaming(ala SAX) | In memory tree(ala DOM) | Buffered Streaming |
cpu和内存效率 | good | Varies | good | Varies | good |
Forward Only | yes | no | yes | no | yes |
读取文件 | yes | yes | yes | yes | no |
写入文件 | no | yes | no | yes | yes |
特征: | |||||
创建 sheet/行、cell | no | yes | no | yes | yes |
cell 样式 | no | yes | no | yes | yes |
删除 sheet/行、cell | no | yes | no | yes | no |
行移位变换, | no | yes | no | yes | no |
sheet克隆 | no | yes | no | yes | no |
公式计算 | no | yes | no | yes | no |
cell comments | no | yes | no | yes | no |
图片 | no | yes | no | yes | yes |
1.eventmodel 只能读,不能修改文件,内存占用率地 2.SXXF只能写不能读 3.既读又写用usermodel,但是hssf是内存占有率最小的 | |||||
以上是关于https://poi.apache.org/components/spreadsheet/index.html(翻译1)的主要内容,如果未能解决你的问题,请参考以下文章