poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Syed Mudassir Ahmed <syed.mudas...@gaianconsultants.com>
Subject Re: Is it POI error starting 3.14 version onwards
Date Tue, 15 May 2018 10:15:05 GMT
Yes, pls find the file attached here.

Thanks,


On Tue, May 15, 2018 at 3:43 PM, Tim Allison <tallison@apache.org> wrote:

> Any chanc you can share the file?
>
> On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
> syed.mudassir@gaianconsultants.com> wrote:
>
> > Hi,
> >   I am trying to read data from a XLSX sheet via XSSFSheetXMLHandler.
> The
> > source code is below.
> >
> >   public static void main(String str[]) throws Exception {
> >         String filePath
> >                 = "/home/gaian/Desktop/salary.xlsx";
> >         File file = new File(filePath);
> >         InputStream inputStream = new FileInputStream(file);
> >         OPCPackage pkg = OPCPackage.open(inputStream);
> >
> >         SheetContentsHandler sheetContentsHandler = new
> > SheetContentsHandler() {
> >             @Override
> >             public void startRow(int rowIndex) {
> >             }
> >
> >             @Override
> >             public void endRow(int i) {
> >             }
> >
> >             @Override
> >             public void cell(String cell, String formattedValue,
> > XSSFComment c) {
> >                 System.out.println("cell encountered with addess:<" +
> cell
> >                         + "> and value:<" + formattedValue + ">");
> >             }
> >
> >             @Override
> >             public void headerFooter(String text, boolean isHeader,
> String
> > tagName) {
> >                 System.out.println("headerFooter()");
> >             }
> >         };
> >
> >         ReadOnlySharedStringsTable strings = new
> > ReadOnlySharedStringsTable(pkg);
> >         XSSFReader xssfReader = new XSSFReader(pkg);
> >         StylesTable styles = xssfReader.getStylesTable();
> >         XSSFReader.SheetIterator worksheets = (XSSFReader.SheetIterator)
> > xssfReader.getSheetsData();
> >         InputStream stream = worksheets.next();
> >         SAXParserFactory saxFactory = SAXParserFactory.newInstance();
> >         XMLReader sheetParser = saxFactory.newSAXParser().
> getXMLReader();
> >
> >         ContentHandler handler
> >                 = new XSSFSheetXMLHandler(styles, strings,
> > sheetContentsHandler, false);
> >
> >         sheetParser.setContentHandler(handler);
> >         sheetParser.parse(new InputSource(stream));
> >     }
> >
> >   When I use the POI version 3.13, I am getting the following output:
> >
> > cell encountered with addess:<A1> and value:<Salary>
> > cell encountered with addess:<A2> and value:<99.965432>
> >
> >   The moment I switch to version 3.14 or higher, I am no longer getting
> > any output.
> >
> >   Can someone pls let me know if any more code changes needed if I switch
> > to 3.14 or higher?  I even checked the test cases in Apache POI 3.17
> > sources but was shocked not to find any there.  Any example/references
> that
> > I can go through pls?  This is blocker for one of my applications.
> >
> >
> > Thanks,
> >
> >
>

Mime
View raw message