can not processFormulas while use createSxssfTransformer

Issue #33 resolved
Felix Xu
created an issue

I have big data need to export by excel, I've got suggestion from http://stackoverflow.com/questions/32001231/performance-problems-after-upgrading-to-jxls-2-2-3

code:

    InputStream tplIs = getClass().getClassLoader().getResourceAsStream(xlsx_template);
    OutputStream os = new FileOutputStream(new File(file));

    Workbook workbook = WorkbookFactory.create(tplIs);
    Transformer transformer = PoiTransformer.createSxssfTransformer(workbook);

    InputStream cfgIs = getClass().getClassLoader().getResourceAsStream(xml_config);
    AreaBuilder areaBuilder = new XmlAreaBuilder(cfgIs, transformer);
    List<Area> xlsAreaList = areaBuilder.build();
    Area xlsArea = xlsAreaList.get(0);

    Context context = new PoiContext();
    context.putVar("coupons", list);

    xlsArea.applyAt(new CellRef("Template1!A1"), context);

// xlsArea.processFormulas(); // will throw java.lang.IllegalArgumentException: Attempting to write a row[0] in the range [0,100] that is already written to disk.

    Workbook workbook1 = ((PoiTransformer) transformer).getWorkbook();

Can I call the processFormulas method by use POI SXSSF? If not, how to resolve it? Thanks very much!

Comments (2)

  1. Mrusful l

    See how work POI SXSSF - https://poi.apache.org/spreadsheet/

    Due to the streaming nature of the implementation formula evaluation is not supported.

    Message

    java.lang.IllegalArgumentException: Attempting to write a row[0] in the range [0,100] that is already written to disk
    

    from the SXSSFSheet and says that you try to write row that already streamed to disk.

    Maybe this will help you

    ((PoiTransformer) transformer).getWorkbook().setForceFormulaRecalculation(true);
    

    If i understand correct you can not use together SXSSF implementation and xlsArea.processFormulas() becouse xlsArea.processFormulas() can initialize write to already streamed rows.

    Please correct me if i wrong

  2. Log in to comment