Class XlsxToCsvUtil.SheetInfo

  • Enclosing class:
    XlsxToCsvUtil

    public class XlsxToCsvUtil.SheetInfo
    extends Object
    Represents a single sheet in a workbook. Use it to get access to a CSV Input stream that is generated from the table data. It can also be used to get access to the actual underlying Cell element for reading data directly.
    • Field Detail

      • sheet

        private final org.apache.poi.ss.usermodel.Sheet sheet
      • dataFormat

        private final org.apache.poi.ss.usermodel.DataFormatter dataFormat
      • formulaEval

        private final org.apache.poi.ss.usermodel.FormulaEvaluator formulaEval
      • firstRow

        private final int firstRow
      • lastRow

        private final int lastRow
      • firstColumn

        private final int firstColumn
      • lastColumn

        private final int lastColumn
      • csvBytes

        private byte[] csvBytes
    • Constructor Detail

      • SheetInfo

        SheetInfo​(org.apache.poi.ss.usermodel.Sheet sheet)
    • Method Detail

      • getName

        public String getName()
        Get the name of the sheet.
      • getFirstRow

        public int getFirstRow()
        Get the row number for the first row that contains data.
      • getLastRow

        public int getLastRow()
        Get the row number for the last row that contains data.
      • getFirstColumn

        public int getFirstColumn()
        Get the column number for the first column that contains data.
      • getLastColumn

        public int getLastColumn()
        Get the column number for the last column that contains data.
      • getCell

        public org.apache.poi.ss.usermodel.Cell getCell​(int row,
                                                        int col)
        Get the cell at the specified row and column.
        Returns:
        A Cell instance or null
      • getCellValueAsString

        public String getCellValueAsString​(org.apache.poi.ss.usermodel.Cell cell)
        Get the the cell value as a string. Numeric cells are are checked if the seem to have a date-like format syntax (with or without time). If so, the value is formatted with the date or timestamp formatter, otherwise with the number formatter. If the required formatter has not been set, the value is formatted with the built-in formatter from Excel.
      • getCellValueAsNumber

        public Double getCellValueAsNumber​(org.apache.poi.ss.usermodel.Cell cell,
                                           NumberFormat parser,
                                           boolean nullIfException)
        Get the cell value as a number. If the cell is a numeric cell, the value is returned directly, otherwise the given parser is used to parse the string data from cell, via Type.parseString(String, NumberFormat, boolean)
      • getCellValueAsDate

        public Date getCellValueAsDate​(org.apache.poi.ss.usermodel.Cell cell,
                                       Formatter<Date> parser,
                                       boolean nullIfException)
        Get the cell value as a date. If the cell is a numeric cell, the value is returned directly as if it was a date (the style format string is NOT checked), otherwise the given parser is used to parse the string data from cell, via Type.parseString(String, Formatter, boolean)
      • parseToCsv

        public InputStream parseToCsv()
        Convert the sheet to a CSV and get an InputStream for reading the data. Note that the CSV will only contain data for the range of cells between firstRow, lastRow, firstColumn and lastColumn.
      • parseToBytes

        private void parseToBytes()