java.lang.Object
org.qubership.atp.dataset.service.direct.importexport.converters.XlsxToListConverter

public class XlsxToListConverter extends Object
A rudimentary XLSX -> ListMap processor modeled on the POI sample program XlsxToListConverter from the package org.apache.poi.hssf.eventusermodel.examples. Read using a SAX parser to keep the memory footprint relatively small, so this should be able to read enormous workbooks. The styles table and the shared-string table must be kept in memory. The standard POI styles table class is used, but a custom (read-only) class is used for the shared string table because the standard POI SharedStringsTable grows very quickly with the number of unique strings.
  • Constructor Summary

    Constructors
    Constructor
    Description
    XlsxToListConverter(org.apache.poi.openxml4j.opc.OPCPackage pkg, List<Map<Integer,String>> sheetConvertList)
    Creates a new XLSX -> ListMap converter.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Initiates the processing of the XLS workbook file to List.
    void
    processSheet(org.apache.poi.xssf.model.Styles styles, org.apache.poi.xssf.model.SharedStrings strings, org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler sheetHandler, InputStream sheetInputStream)
    Parses and shows the content of one sheet using the specified styles and shared-strings tables.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XlsxToListConverter

      public XlsxToListConverter(org.apache.poi.openxml4j.opc.OPCPackage pkg, List<Map<Integer,String>> sheetConvertList)
      Creates a new XLSX -> ListMap converter. output. The sheetConvertList to output the ListMap to.
      Parameters:
      pkg - The XLSX package to process
      sheetConvertList - The XLSX converted to ListMap
  • Method Details

    • processSheet

      public void processSheet(org.apache.poi.xssf.model.Styles styles, org.apache.poi.xssf.model.SharedStrings strings, org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler sheetHandler, InputStream sheetInputStream) throws IOException, SAXException
      Parses and shows the content of one sheet using the specified styles and shared-strings tables.
      Parameters:
      styles - The table of styles that may be referenced by cells in the sheet
      strings - The table of strings that may be referenced by cells in the sheet
      sheetInputStream - The stream to read the sheet-data from.
      Throws:
      IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
      SAXException - if parsing the XML data fails.
    • process

      public void process() throws IOException, org.apache.poi.openxml4j.exceptions.OpenXML4JException, SAXException
      Initiates the processing of the XLS workbook file to List.
      Throws:
      IOException - If reading the data from the package fails.
      SAXException - if parsing the XML data fails.
      org.apache.poi.openxml4j.exceptions.OpenXML4JException