poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shiva Kumar" <shiv...@pawaa.com>
Subject Efficient way to read shared strings.
Date Mon, 27 Jul 2015 07:38:44 GMT
Hi, I am using XLSX2CSV class for converting XLSX to HTML with some
modifications. The method where I have a question is below.

 

public void process()

            throws IOException, OpenXML4JException,
ParserConfigurationException, SAXException, XMLStreamException

    {

        ReadOnlySharedStringsTable strings = new
ReadOnlySharedStringsTable(this.xlsxPackage); //-> Any memory efficient
solution.

        XSSFReader xssfReader = new XSSFReader(this.xlsxPackage);

        StylesTable styles = xssfReader.getStylesTable();

        XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator)
xssfReader.getSheetsData();

        

        htmlWriter.writeStartElement("html");
// this is my code which is writing body of html.

 
htmlWriter.writeCharacters(System.lineSeparator());

                                htmlWriter.writeStartElement("head");

 
htmlWriter.writeCharacters(System.lineSeparator());               

                                htmlWriter.writeStartElement("title");

                                htmlWriter.writeCharacters(name);

                                htmlWriter.writeEndElement();

                                htmlWriter.writeEndElement();

                                htmlWriter.writeStartElement("body");
// this is my code which is writing body of html.

        

        int index = 0;

        while (iter.hasNext()) {

            InputStream stream = iter.next();

            String sheetName = iter.getSheetName();

            processSheet(styles, strings, stream, sheetName, index);   //
processing each sheet custom implementation.

            stream.close();

            ++index;

        }

    }

 

PROBLEM DISCRIPTION:

                The method process() uses ReadOnlySharedStringsTable class
to construct and store all strings in list by reading "sharedStrings.xml",
but it causes memory issues for very large files with large strings, Is
there any other memory efficient way provided by POI.

 

Thank You


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message