https://bz.apache.org/bugzilla/show_bug.cgi?id=68985

            Bug ID: 68985
           Summary: Unable to edit cell type on excel file that was
                    generated via Apache Poi API (edit)
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: jengl...@xifin.com
  Target Milestone: ---

To give a quick synopsis, I'm using Apache POI API to generate an excel file.
After the file is generated, I am unable to apply formulas to the any of the
modified rows. The reason appears to be related to the cell type of the cells,
which cannot be updated after the file has generated. Even if I manually change
the cell type of the cells via the Excel spreadsheet, the changes do not take
effect.

To reproduce, simply run the test below and open the generate excel file. If
you manually add '=SUM(A1:A5)' to any cell to get the sum of the cells, you
will notice that the formula is not calculating correctly.

Any help would be greatly appreciated.

Thank you

import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;

public class TestExcelWriter
{
    public static void main(String[] args) throws Exception
    {
        XSSFWorkbook workbook = new XSSFWorkbook();
        workbook.setForceFormulaRecalculation(true);
        XSSFSheet sheet = workbook.createSheet();

        int row = 0;
        String[] values = {"1.00", "2.00", "3.00", "4.00", "5.00",};
        for (String value : values)
        {
            XSSFRow newRow = sheet.createRow(row);
            XSSFCell newCell = newRow.createCell(0);
            newCell.setCellType(CellType.NUMERIC);
            newCell.setCellValue(value);
            row++;
        }

        FileOutputStream out = new FileOutputStream("outputFile.xlsx");
        workbook.write(out);
        out.close();
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to