Search code examples
javaapache-poiexcel-charts

SXSSFWorkbook and XSSFSheet


I need to generate a multi sheet excel report, one sheet has the main table and it can get quite large so using SXSSFWorkbook makes sense, on the other hand in another sheet I need to put few charts and I haven't seen such option with SXSSFSheet (only with XSSFSheets), is it possible to have and XSSFSheet in SXSSFWorkbook or is there an workaround?

I am using apache poi 4.1.2


Solution

  • Turns out SXSSFWorkbook can be a decorator of XSSFWorkbook, so you can add sheets via anyone of them (I wouldn't push this method to its limits, but for me it worked):

        XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
        SXSSFWorkbook workbook = new SXSSFWorkbook(xssfWorkbook...
    
        XSSFSheet sheet = xssfWorkbook.createSheet...