You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN" <Pa...@HILL.af.mil> on 2008/09/26 18:57:01 UTC

Order of sheets returned by sheets.next()

I am using POI 3.5.1 beta to process excel files.  First I get the names
of the sheets by parsing the workbook.xml file .  I then use something
close to the  code below to determine which sheets I want to process.
Problem is, the order returned by sheets.hasNext() doesn't seem to match
the order the sheets are in the workbook.xml file.  How can I determine
which order the sheets.hasNext() will give me sheets to work with? Or,
is there a better way to selectively process sheets based on the sheet
title?

 

Thanks in advance for any suggestions.

 

 

String[] sheetNames = {"sheet1", "sheet2", "sheet3"};//this is actually
pulled from the workbook.xml using Sax.

Package pkg = Package.open(filePath);

XSSFReader r = new XSSFReader(pkg);

SharedStringsTable sst = r.getSharedStringsTable();

Iterator<InputStream> sheets = r.getSheetsData();

for (int x = 0; sheets.hasNext(); x++) {

                InputStream sheet = sheets.next();

if(sheetNames[x].equals("sheet2"))

                {

                                // parser sheet here.

                                //Sheet data that I parse is not the
data for "sheet 2"

                }

}

 

Thanks.

Paul Dobson


RE: Order of sheets returned by sheets.next()

Posted by "Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN" <Pa...@HILL.af.mil>.
I'll take a look.  Thanks for the suggestion.

-----Original Message-----
From: Nick Burch [mailto:nick@torchbox.com] 
Sent: Friday, September 26, 2008 12:41 PM
To: POI Users List
Subject: RE: Order of sheets returned by sheets.next()

On Fri, 26 Sep 2008, Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN wrote:
> I have super large excel files.  Would that require the whole Workbook

> to be in memory?  I think I am restricted to only use event driven 
> processing due to the file size.

Ah, yes. OK, what you want to do is take a look at how 
xssf.usermodel.XSSFWorkbook does it, then do the same thing only event 
based. (IIRC, it involves using the relations on the workbook, and the
ids 
for the relations are in the sheet definition on the workbook)

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


RE: Order of sheets returned by sheets.next()

Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 26 Sep 2008, Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN wrote:
> I have super large excel files.  Would that require the whole Workbook 
> to be in memory?  I think I am restricted to only use event driven 
> processing due to the file size.

Ah, yes. OK, what you want to do is take a look at how 
xssf.usermodel.XSSFWorkbook does it, then do the same thing only event 
based. (IIRC, it involves using the relations on the workbook, and the ids 
for the relations are in the sheet definition on the workbook)

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


RE: Order of sheets returned by sheets.next()

Posted by "Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN" <Pa...@HILL.af.mil>.
I have super large excel files.  Would that require the whole Workbook
to be in memory?  I think I am restricted to only use event driven
processing due to the file size.

-----Original Message-----
From: Nick Burch [mailto:nick@torchbox.com] 
Sent: Friday, September 26, 2008 11:06 AM
To: POI Users List
Subject: Re: Order of sheets returned by sheets.next()

On Fri, 26 Sep 2008, Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN wrote:
> Or, is there a better way to selectively process sheets based on the 
> sheet title?

"public Sheet getSheet(String name)" on ss.usermodel.Workbook ?

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Order of sheets returned by sheets.next()

Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 26 Sep 2008, Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN wrote:
> Or, is there a better way to selectively process sheets based on the 
> sheet title?

"public Sheet getSheet(String name)" on ss.usermodel.Workbook ?

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


RE: Order of sheets returned by sheets.next()

Posted by "Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN" <Pa...@HILL.af.mil>.
Yegor,

Those changes are very helpful. Thanks for your contributions.

Paul

-----Original Message-----
From: Yegor Kozlov [mailto:yegor@dinom.ru] 
Sent: Wednesday, October 01, 2008 10:17 AM
To: POI Users List
Subject: Re: Order of sheets returned by sheets.next()

Fixed in r700821

I also made the XSSFReader.SheetIterator public and added
SheetIterator.getSheetName():

   XSSFReader.SheetIterator it =
(XSSFReader.SheetIterator)reader.getSheetsData();

   while(it.hasNext()) {
     String sheetName =  it.getSheetName(); //available only if you cast
to XSSFReader.SheetIterator
     InputStream inp = it.next();
     .....
   }

Yegor
> 
>> I am using POI 3.5.1 beta to process excel files.  First I get the
names
>> of the sheets by parsing the workbook.xml file .  I then use
something
>> close to the  code below to determine which sheets I want to process.
>> Problem is, the order returned by sheets.hasNext() doesn't seem to
match
>> the order the sheets are in the workbook.xml file.  How can I
determine
>> which order the sheets.hasNext() will give me sheets to work with?
Or,
>> is there a better way to selectively process sheets based on the
sheet
>> title?
>>
> 
> The sheet iterator in XSSFReader  returns sheets ordered by their 
> relationship ID, that is in physical order.
> I'm going to fix it and make XSSFReader  follow the order of sheets in

> workbook.xml.
> 
> Yegor
> 
>>  
>>
>> Thanks in advance for any suggestions.
>>
>>  
>>
>>  
>>
>> String[] sheetNames = {"sheet1", "sheet2", "sheet3"};//this is
actually
>> pulled from the workbook.xml using Sax.
>>
>> Package pkg = Package.open(filePath);
>>
>> XSSFReader r = new XSSFReader(pkg);
>>
>> SharedStringsTable sst = r.getSharedStringsTable();
>>
>> Iterator<InputStream> sheets = r.getSheetsData();
>>
>> for (int x = 0; sheets.hasNext(); x++) {
>>
>>                 InputStream sheet = sheets.next();
>>
>> if(sheetNames[x].equals("sheet2"))
>>
>>                 {
>>
>>                                 // parser sheet here.
>>
>>                                 //Sheet data that I parse is not the
>> data for "sheet 2"
>>
>>                 }
>>
>> }
>>
>>  
>>
>> Thanks.
>>
>> Paul Dobson
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Order of sheets returned by sheets.next()

Posted by Yegor Kozlov <ye...@dinom.ru>.
Fixed in r700821

I also made the XSSFReader.SheetIterator public and added SheetIterator.getSheetName():

   XSSFReader.SheetIterator it = (XSSFReader.SheetIterator)reader.getSheetsData();

   while(it.hasNext()) {
     String sheetName =  it.getSheetName(); //available only if you cast to XSSFReader.SheetIterator
     InputStream inp = it.next();
     .....
   }

Yegor
> 
>> I am using POI 3.5.1 beta to process excel files.  First I get the names
>> of the sheets by parsing the workbook.xml file .  I then use something
>> close to the  code below to determine which sheets I want to process.
>> Problem is, the order returned by sheets.hasNext() doesn't seem to match
>> the order the sheets are in the workbook.xml file.  How can I determine
>> which order the sheets.hasNext() will give me sheets to work with? Or,
>> is there a better way to selectively process sheets based on the sheet
>> title?
>>
> 
> The sheet iterator in XSSFReader  returns sheets ordered by their 
> relationship ID, that is in physical order.
> I'm going to fix it and make XSSFReader  follow the order of sheets in 
> workbook.xml.
> 
> Yegor
> 
>>  
>>
>> Thanks in advance for any suggestions.
>>
>>  
>>
>>  
>>
>> String[] sheetNames = {"sheet1", "sheet2", "sheet3"};//this is actually
>> pulled from the workbook.xml using Sax.
>>
>> Package pkg = Package.open(filePath);
>>
>> XSSFReader r = new XSSFReader(pkg);
>>
>> SharedStringsTable sst = r.getSharedStringsTable();
>>
>> Iterator<InputStream> sheets = r.getSheetsData();
>>
>> for (int x = 0; sheets.hasNext(); x++) {
>>
>>                 InputStream sheet = sheets.next();
>>
>> if(sheetNames[x].equals("sheet2"))
>>
>>                 {
>>
>>                                 // parser sheet here.
>>
>>                                 //Sheet data that I parse is not the
>> data for "sheet 2"
>>
>>                 }
>>
>> }
>>
>>  
>>
>> Thanks.
>>
>> Paul Dobson
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Order of sheets returned by sheets.next()

Posted by Yegor Kozlov <ye...@dinom.ru>.
> I am using POI 3.5.1 beta to process excel files.  First I get the names
> of the sheets by parsing the workbook.xml file .  I then use something
> close to the  code below to determine which sheets I want to process.
> Problem is, the order returned by sheets.hasNext() doesn't seem to match
> the order the sheets are in the workbook.xml file.  How can I determine
> which order the sheets.hasNext() will give me sheets to work with? Or,
> is there a better way to selectively process sheets based on the sheet
> title?
> 

The sheet iterator in XSSFReader  returns sheets ordered by their relationship ID, that is in physical order.
I'm going to fix it and make XSSFReader  follow the order of sheets in workbook.xml.

Yegor

>  
> 
> Thanks in advance for any suggestions.
> 
>  
> 
>  
> 
> String[] sheetNames = {"sheet1", "sheet2", "sheet3"};//this is actually
> pulled from the workbook.xml using Sax.
> 
> Package pkg = Package.open(filePath);
> 
> XSSFReader r = new XSSFReader(pkg);
> 
> SharedStringsTable sst = r.getSharedStringsTable();
> 
> Iterator<InputStream> sheets = r.getSheetsData();
> 
> for (int x = 0; sheets.hasNext(); x++) {
> 
>                 InputStream sheet = sheets.next();
> 
> if(sheetNames[x].equals("sheet2"))
> 
>                 {
> 
>                                 // parser sheet here.
> 
>                                 //Sheet data that I parse is not the
> data for "sheet 2"
> 
>                 }
> 
> }
> 
>  
> 
> Thanks.
> 
> Paul Dobson
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Delete slides from SlideShow

Posted by Yegor Kozlov <ye...@dinom.ru>.
Deletion of slides is not yet supported.
A possible workaround is to grab the Document record, then the slide SlideListWithText entry and remove the corresponing 
SlideAtomsSet.

Document doc = ppt.getDocumentRecord();
SlideListWithText slwt = doc.getSlideListWithTexts();

//investigate how to remove the slide's SlideAtomsSet. It can be tricky.

Yegor

> Hi All. Is any workaround to delete slides from PPT present?
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Delete slides from SlideShow

Posted by Constantin Volozhin <cv...@pragmaticsoft.com>.
Hi All. Is any workaround to delete slides from PPT present?



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Simple

Posted by Awais Bajwa <ab...@macrosoftinc.com>.
Hi All,

One simple functionality is not working, I am not sure if it is true.

I need to set size of the the cell, so that the text should appear properly,
and I couldn't find any method for tht???????


Regards
A.B




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org