excel-streaming-reader icon indicating copy to clipboard operation
excel-streaming-reader copied to clipboard

DataFormat : StreamingWorkbook#createDataFormat()

Open clemensdev opened this issue 7 years ago • 3 comments

First of all I (being pained by OOMs due to POI Excel imports ;) ) would like to say how impressed I am by the low footprint of this streaming reader. Unfortunately we need to access workbook.createDataFormat().getFormat( dataFormatNr ) to get cell (formatting) details. But StreamingWorkbook#createDataFormat() is not supported and hence throws UnsupportedOperationException() What would be the "right way" to get the DataFormat of a workbook?

clemensdev avatar Dec 01 '17 05:12 clemensdev

I have just noticed that the StreamingWorkbookReader has the sytles(Table). What if these became a new field (instead of the local variable) and would be provided through StreamingWorkbookReader#getStylesTable() ? Then StreamingWorkbook could implement createDataFormat as follows:

  public DataFormat createDataFormat() {
	if (formatter == null) {
          formatter = new StreamingDataFormat(reader.getStylesTable());
      }
      return formatter;
  }

StreamingDataFormat being a copy of XSSFDataFormat

clemensdev avatar Dec 01 '17 06:12 clemensdev

That certainly sounds like it could work. I don't have a workbook to test with though, would you be able to implement this in a PR and include one?

monitorjbl avatar Dec 01 '17 18:12 monitorjbl

would you be able to implement this in a PR

me being git newbie, I hope you can live with a simple patch?

stylesTable.zip

clemensdev avatar Dec 03 '17 17:12 clemensdev