Re: Is it POI error starting 3.14 version onwards

2018-05-17 Thread pj.fanning
https://github.com/apache/poi/blob/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java

https://github.com/apache/poi/blob/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java

These are our 2 main streaming xlsx reading examples and both use SAXHelper
to create the XMLReader (already).



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

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



RE: Is it POI error starting 3.14 version onwards

2018-05-17 Thread Murphy, Mark
You need to apply a style to the cell. The style can include a number format.

DataFormat format = workbook.createDataFormat();
short fmt = format.getFormat("#0.0");
CellStyle style = workbook.createCellStyle();
style.setDataFormat(fmt);

…
cell.setCellStyle(style);


From: Syed Mudassir Ahmed [mailto:syed.mudas...@gaianconsultants.com]
Sent: Wednesday, May 16, 2018 11:56 PM
To: POI Users List 
Subject: Re: Is it POI error starting 3.14 version onwards

And one more thing, this is my source code:

public static void main(String str[]) throws Exception {
Map input = new LinkedHashMap<>();
SXSSFWorkbook workbook = new SXSSFWorkbook();
OutputStream os = new FileOutputStream(
new File("/home/gaian/Desktop/Sal.xlsx"));
workbook.setCompressTempFiles(true);
SXSSFSheet sheet = workbook.createSheet("firstSheet");
SXSSFRow row = sheet.createRow(0);
SXSSFCell cell = row.createCell(0);
cell.setCellValue("salary");
cell.setCellType(CellType.STRING);
row = sheet.createRow(1);
cell = row.createCell(0);
cell.setCellValue(new Double("4.0"));
cell.setCellType(CellType.NUMERIC);
workbook.write(os);
os.close();
workbook.close();
System.out.println("done creating excel workbook...");
}

I am creating a workbook and writing a value (4.0) as double in a sheet.  But 
when I open the sheet, I see the integral value 4 instead of decimal 4.0.

Any settings I need to do in my code to get the value 4.0?

Thanks.

Thanks,
[cid:ii_14fd4e82bb9756bc]

On Thu, May 17, 2018 at 9:07 AM, Syed Mudassir Ahmed 
mailto:syed.mudas...@gaianconsultants.com>> 
wrote:
Thanks so much Tim and Fanning.  Both of your suggestions are working out.  I 
would suggest better to have such example in the test case section of your 
source folder.

Thanks,
[cid:ii_14fd4e82bb9756bc]

On Wed, May 16, 2018 at 6:49 PM, Tim Allison 
mailto:talli...@apache.org>> wrote:
You need to make your SAXReader namespace aware:

saxFactory.setNamespaceAware(true);


On Wed, May 16, 2018 at 8:59 AM, Tim Allison 
mailto:talli...@apache.org>> wrote:

> Sorry for my delay.  I just tested your file with Apache Tika 1.18 which
> uses POI 3.17..., and I got:
>
>
> Sheet1
>   Salary
> 99.965432
> 
> 
> Sheet2
> 
> 
> Sheet3
> 
> 
> 
>
> That's promising...  Let me take a look at your example code.
>
> On Wed, May 16, 2018 at 1:31 AM, Syed Mudassir Ahmed mailto:syed.mudassir@%0b>> gaianconsultants.com<http://gaianconsultants.com>> 
wrote:
>
>> any update on this pls?  This is blocking me.
>>
>> Thanks,
>>
>>
>> On Tue, May 15, 2018 at 3:45 PM, Syed Mudassir Ahmed <
>> syed.mudas...@gaianconsultants.com<mailto:syed.mudas...@gaianconsultants.com>>
>>  wrote:
>>
>>> Yes, pls find the file attached here.
>>>
>>> Thanks,
>>>
>>>
>>> On Tue, May 15, 2018 at 3:43 PM, Tim Allison 
>>> mailto:talli...@apache.org>>
>>> wrote:
>>>
>>>> Any chanc you can share the file?
>>>>
>>>> On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
>>>> syed.mudas...@gaianconsultants.com<mailto:syed.mudas...@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:<" +
>>

Re: Is it POI error starting 3.14 version onwards

2018-05-16 Thread Syed Mudassir Ahmed
And one more thing, this is my source code:

public static void main(String str[]) throws Exception {
Map input = new LinkedHashMap<>();
SXSSFWorkbook workbook = new SXSSFWorkbook();
OutputStream os = new FileOutputStream(
new File("/home/gaian/Desktop/Sal.xlsx"));
workbook.setCompressTempFiles(true);
SXSSFSheet sheet = workbook.createSheet("firstSheet");
SXSSFRow row = sheet.createRow(0);
SXSSFCell cell = row.createCell(0);
cell.setCellValue("salary");
cell.setCellType(CellType.STRING);
row = sheet.createRow(1);
cell = row.createCell(0);
cell.setCellValue(new Double("4.0"));
cell.setCellType(CellType.NUMERIC);
workbook.write(os);
os.close();
workbook.close();
System.out.println("done creating excel workbook...");
}

I am creating a workbook and writing a value (4.0) as double in a sheet.
But when I open the sheet, I see the integral value 4 instead of decimal
4.0.

Any settings I need to do in my code to get the value 4.0?

Thanks.

Thanks,


On Thu, May 17, 2018 at 9:07 AM, Syed Mudassir Ahmed <
syed.mudas...@gaianconsultants.com> wrote:

> Thanks so much Tim and Fanning.  Both of your suggestions are working
> out.  I would suggest better to have such example in the test case section
> of your source folder.
>
> Thanks,
>
>
> On Wed, May 16, 2018 at 6:49 PM, Tim Allison  wrote:
>
>> You need to make your SAXReader namespace aware:
>>
>> saxFactory.setNamespaceAware(true);
>>
>>
>> On Wed, May 16, 2018 at 8:59 AM, Tim Allison  wrote:
>>
>> > Sorry for my delay.  I just tested your file with Apache Tika 1.18 which
>> > uses POI 3.17..., and I got:
>> >
>> >
>> > Sheet1
>> >   Salary
>> > 99.965432
>> > 
>> > 
>> > Sheet2
>> > 
>> > 
>> > Sheet3
>> > 
>> > 
>> > 
>> >
>> > That's promising...  Let me take a look at your example code.
>> >
>> > On Wed, May 16, 2018 at 1:31 AM, Syed Mudassir Ahmed > > gaianconsultants.com> wrote:
>> >
>> >> any update on this pls?  This is blocking me.
>> >>
>> >> Thanks,
>> >>
>> >>
>> >> On Tue, May 15, 2018 at 3:45 PM, Syed Mudassir Ahmed <
>> >> syed.mudas...@gaianconsultants.com> wrote:
>> >>
>> >>> Yes, pls find the file attached here.
>> >>>
>> >>> Thanks,
>> >>>
>> >>>
>> >>> On Tue, May 15, 2018 at 3:43 PM, Tim Allison 
>> >>> wrote:
>> >>>
>>  Any chanc you can share the file?
>> 
>>  On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
>>  syed.mudas...@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().getX
>>  MLReader();
>>  >
>>  > 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

Re: Is it POI error starting 3.14 version onwards

2018-05-16 Thread Syed Mudassir Ahmed
Thanks so much Tim and Fanning.  Both of your suggestions are working out.
I would suggest better to have such example in the test case section of
your source folder.

Thanks,


On Wed, May 16, 2018 at 6:49 PM, Tim Allison  wrote:

> You need to make your SAXReader namespace aware:
>
> saxFactory.setNamespaceAware(true);
>
>
> On Wed, May 16, 2018 at 8:59 AM, Tim Allison  wrote:
>
> > Sorry for my delay.  I just tested your file with Apache Tika 1.18 which
> > uses POI 3.17..., and I got:
> >
> >
> > Sheet1
> >   Salary
> > 99.965432
> > 
> > 
> > Sheet2
> > 
> > 
> > Sheet3
> > 
> > 
> > 
> >
> > That's promising...  Let me take a look at your example code.
> >
> > On Wed, May 16, 2018 at 1:31 AM, Syed Mudassir Ahmed  > gaianconsultants.com> wrote:
> >
> >> any update on this pls?  This is blocking me.
> >>
> >> Thanks,
> >>
> >>
> >> On Tue, May 15, 2018 at 3:45 PM, Syed Mudassir Ahmed <
> >> syed.mudas...@gaianconsultants.com> wrote:
> >>
> >>> Yes, pls find the file attached here.
> >>>
> >>> Thanks,
> >>>
> >>>
> >>> On Tue, May 15, 2018 at 3:43 PM, Tim Allison 
> >>> wrote:
> >>>
>  Any chanc you can share the file?
> 
>  On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
>  syed.mudas...@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().getX
>  MLReader();
>  >
>  > 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: and value:
>  > cell encountered with addess: 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,
>  >
>  >
> 
> >>>
> >>>
> >>
> >
>


Re: Is it POI error starting 3.14 version onwards

2018-05-16 Thread pj.fanning
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java

org.apache.poi.util.SAXHelper has a newXMLReader() method that creates an
XMLReader instance that satisfies the requirements for this use case.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

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



Re: Is it POI error starting 3.14 version onwards

2018-05-16 Thread Tim Allison
You need to make your SAXReader namespace aware:

saxFactory.setNamespaceAware(true);


On Wed, May 16, 2018 at 8:59 AM, Tim Allison  wrote:

> Sorry for my delay.  I just tested your file with Apache Tika 1.18 which
> uses POI 3.17..., and I got:
>
>
> Sheet1
>   Salary
> 99.965432
> 
> 
> Sheet2
> 
> 
> Sheet3
> 
> 
> 
>
> That's promising...  Let me take a look at your example code.
>
> On Wed, May 16, 2018 at 1:31 AM, Syed Mudassir Ahmed  gaianconsultants.com> wrote:
>
>> any update on this pls?  This is blocking me.
>>
>> Thanks,
>>
>>
>> On Tue, May 15, 2018 at 3:45 PM, Syed Mudassir Ahmed <
>> syed.mudas...@gaianconsultants.com> wrote:
>>
>>> Yes, pls find the file attached here.
>>>
>>> Thanks,
>>>
>>>
>>> On Tue, May 15, 2018 at 3:43 PM, Tim Allison 
>>> wrote:
>>>
 Any chanc you can share the file?

 On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
 syed.mudas...@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().getX
 MLReader();
 >
 > 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: and value:
 > cell encountered with addess: 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,
 >
 >

>>>
>>>
>>
>


Re: Is it POI error starting 3.14 version onwards

2018-05-16 Thread Tim Allison
Sorry for my delay.  I just tested your file with Apache Tika 1.18 which
uses POI 3.17..., and I got:


Sheet1
  Salary
99.965432


Sheet2


Sheet3




That's promising...  Let me take a look at your example code.

On Wed, May 16, 2018 at 1:31 AM, Syed Mudassir Ahmed <
syed.mudas...@gaianconsultants.com> wrote:

> any update on this pls?  This is blocking me.
>
> Thanks,
>
>
> On Tue, May 15, 2018 at 3:45 PM, Syed Mudassir Ahmed  gaianconsultants.com> wrote:
>
>> Yes, pls find the file attached here.
>>
>> Thanks,
>>
>>
>> On Tue, May 15, 2018 at 3:43 PM, Tim Allison  wrote:
>>
>>> Any chanc you can share the file?
>>>
>>> On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
>>> syed.mudas...@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().getX
>>> MLReader();
>>> >
>>> > 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: and value:
>>> > cell encountered with addess: 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,
>>> >
>>> >
>>>
>>
>>
>


Re: Is it POI error starting 3.14 version onwards

2018-05-15 Thread Syed Mudassir Ahmed
any update on this pls?  This is blocking me.

Thanks,


On Tue, May 15, 2018 at 3:45 PM, Syed Mudassir Ahmed <
syed.mudas...@gaianconsultants.com> wrote:

> Yes, pls find the file attached here.
>
> Thanks,
>
>
> On Tue, May 15, 2018 at 3:43 PM, Tim Allison  wrote:
>
>> Any chanc you can share the file?
>>
>> On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
>> syed.mudas...@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().getX
>> MLReader();
>> >
>> > 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: and value:
>> > cell encountered with addess: 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,
>> >
>> >
>>
>
>


Re: Is it POI error starting 3.14 version onwards

2018-05-15 Thread Syed Mudassir Ahmed
Yes, pls find the file attached here.

Thanks,


On Tue, May 15, 2018 at 3:43 PM, Tim Allison  wrote:

> Any chanc you can share the file?
>
> On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
> syed.mudas...@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: and value:
> > cell encountered with addess: 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,
> >
> >
>


salary.xlsx
Description: MS-Excel 2007 spreadsheet

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

Re: Is it POI error starting 3.14 version onwards

2018-05-15 Thread Tim Allison
Any chanc you can share the file?

On Tue, May 15, 2018 at 3:19 AM Syed Mudassir Ahmed <
syed.mudas...@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: and value:
> cell encountered with addess: 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,
>
>