如何复制从大型Excel文件的整个表,而不使用Apache POI解析呢? [英] How to copy entire sheets from large excel files without parsing them using Apache POI?
问题描述
我是新为正式用户,我总是发现我的答案在这里,但现在我得问问。
I am new as an official user, I always found my answers here but now I have got to ask.
我用最后的apache-POI 3.8版本(从2012/03/26)工作,我已经能够操作与多个工作表一个文件,其中只有一个包含数据的一个大的量(超过1000列和10 000行)。
I am working with the last apache-poi 3.8 release (from 2012/03/26) and I have to manipulate a single file with multiple sheets in which only one contains a big amount of data (over 1000 columns and 10 000 rows).
我只需要有更多的列到大表。因此,存在我应该使用SAX来阅读并SXSSF当前工具来改写它。
I only need to had more columns to the big sheet. Therefore, with the current tools that exist I should use SAX to read it and SXSSF to rewrite it.
Excel文件已经美元,每片不同的风格和形象pformatted p $因此这将是有益的,能够使文件的副本,而不大表。
The Excel file is already preformatted with different styles and images in every sheet therefore it will be helpful to be able to make a copy of the file without the big sheet.
还有我的问题:
我怎样才能使板材的使用SAX复印件(从输入流),而不解析它?
我试图做的像这里,但该领域张
在 XSSFWorkbook
的可见性设置为私有。
There goes my question:
How can I make a copy of sheet with SAX (from the input stream in ) without parsing it?
I tried to do like in here but the field sheets
in XSSFWorkbook
has a visibility set to private.
该真棒事情是有东西像 SXSSFWriter.SheetIterator
,如果它是在POI开发未来的计划。
The awesome thing would be to have something like a SXSSFWriter.SheetIterator
if it is in future plans for POI Developers.
感谢您的阅读,
亚瑟
的** *更新的 * 的
**Update**
该文件是太大,能够打开它作为一个普通XSSFWorkbook(OutOfMemoryException异常)。
难道是可以创建和XSSFSheet从InputStream?就像下面这个:
The file is too big to be able to open it as a common XSSFWorkbook (OutOfMemoryException). Could it be possible to create and XSSFSheet from an InputStream? Like in the following:
XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader
.getSheetsData();
int index = 0;
while (iter.hasNext()) {
InputStream stream = iter.next();
String sheetName = iter.getSheetName();
if (!sheetName.equalsIgnoreCase("BigSheetThatIDontWant")) {
Sheet newSheet = new XSSFSheet(stream);
stream.close();
}
++index;
}
非常感谢您的回答。
Thanks a lot for your answers.
推荐答案
您将需要阅读的文件。
关于第二个问题看
公共java.util.Iterator的< XSSFSheet> XSSFWorkbook.iterator()
Allows foreach loops:
XSSFWorkbook wb = new XSSFWorkbook(package);
for(XSSFSheet sheet : wb){
}
这篇关于如何复制从大型Excel文件的整个表,而不使用Apache POI解析呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!