poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 59132] Evaluation of COUNTBLANK() doesn't act as same behavior of Excel
Date Sat, 12 Mar 2016 15:34:31 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=59132

--- Comment #3 from sunnylau175@gmail.com ---
I have written a test code for the issue:

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.CellReference;

public class TestCountBlank {

    public static void main(String[] args) {


        try {
            File excelFile = new File("D:\\test blank.xlsx");

            FileInputStream input;

            input = new FileInputStream(excelFile);
            Workbook workbook = WorkbookFactory.create(input);
            Sheet worksheet = workbook.getSheet("sheet1");

            CellReference ref = new CellReference("B3");

            Row row = worksheet.getRow(ref.getRow());
            Cell cell = row.getCell(ref.getCol());

            cell.setCellValue((String)null);

            FormulaEvaluator evaluator =
workbook.getCreationHelper().createFormulaEvaluator();

            CellReference ref2 = new CellReference("A5");

            Row row2 = worksheet.getRow(ref2.getRow());
            Cell cell2 = row2.getCell(ref2.getCol());

            evaluator.evaluateFormulaCell(cell2);

            FileOutputStream output = new FileOutputStream(excelFile);

            workbook.write(output);
            output.flush();
            output.close();
            workbook.close();



        } catch (EncryptedDocumentException | InvalidFormatException |
IOException e) {

            e.printStackTrace();
        }



    }

}

The code automatically delete "Alice" at cell B3 and evaluate COUNTBLANK()
formula at cell A5, the result of COUNTBLANK() is still zero.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message