poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 55769] Out of Memory Error while reading .Xlsx file
Date Wed, 13 Nov 2013 07:22:38 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=55769

CTcreations <ctvipin007@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #4 from CTcreations <ctvipin007@gmail.com> ---
Am using this code...But it cannot[Neglect] empty cell... Is there any idea to
get null cell in the following code ???

....void parseExcel(File file) throws IOException 
    {

  OPCPackage container;
        try 
        {
            container = OPCPackage.open(file.getAbsolutePath());
            ReadOnlySharedStringsTable strings = new
ReadOnlySharedStringsTable(container);
            XSSFReader xssfReader = new XSSFReader(container);
            StylesTable styles = xssfReader.getStylesTable();
            XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator)
xssfReader.getSheetsData();

            while (iter.hasNext()) 
            {

                InputStream stream = iter.next();
                processSheet(styles, strings, stream);
                stream.close();

            }


    protected static void processSheet(StylesTable styles,
ReadOnlySharedStringsTable strings, InputStream sheetInputStream) throws
IOException, SAXException 
    {

        InputSource sheetSource = new InputSource(sheetInputStream);
        SAXParserFactory saxFactory = SAXParserFactory.newInstance();
        try 
        {
            SAXParser saxParser = saxFactory.newSAXParser();
            XMLReader sheetParser = saxParser.getXMLReader();
            ContentHandler handler = new XSSFSheetXMLHandler(styles, strings,
new SheetContentsHandler() 
            {

                @Override
                public void startRow(int rowNum) 
                {
                    //System.out.println("")

                }
                @Override
                public void endRow() 
                {
                    stringList.add("Row");
                }
                @Override
                public void cell(String cellReference, String formattedValue) 
                {
                    System.out.println(formattedValue);
                }
                @Override
                public void headerFooter(String text, boolean isHeader, String
tagName) 
                {
                    System.out.println(isHeader?"Header " +text:"Footer "+text
);
                }

            }, 
            false//means result instead of formula
            );
            sheetParser.setContentHandler(handler);
            sheetParser.parse(sheetSource);
        } 
        catch 
        {

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


Mime
View raw message