Yegor, Those changes are very helpful. Thanks for your contributions.
Paul -----Original Message----- From: Yegor Kozlov [mailto:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
