Bug 53207

Summary: A formula can not clear by [setCellFormula(null)] in Shared formulas.
Product: POI Reporter: Arimitsu <ishii>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED CLOSED    
Severity: normal CC: onealj, tersitain
Priority: P2    
Version: 3.8-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Attachments: files for test input

Description Arimitsu 2012-05-09 09:55:16 UTC
Created attachment 28749 [details]
files for test input

[attachment : files.zip]
ok.xlsx : D1-D12 has formula
ng.xlsx : D1-D12 has shared formula

A result file[result_ng.xlsx] has break formula.
Open and Rescue by Excel, cells[D11-D12] formula is gone.

The setCellFormula method can not clear formula like this.
(*Exclude the case where only D1 is cleared.)
----------------------------------------------------
<sheetData>
 ..
 <c r="D1" s="2">
  <f t="shared" ref="D1:D12" si="0">B1*C1</f>
 ..
----------------------------------------------------

Test code.

public static void test() {
  formulaTest("ok.xlsx");
  formulaTest("ng.xlsx");
}

public static void formulaTest(String file) {
  ConditionalFormattingTest test = new ConditionalFormattingTest(file);
  test.init();
  XSSFSheet sheet = (XSSFSheet)test.getSheet(0);		
  for (int i=0; i<10; i++) {
    sheet.getRow(i).getCell(3).setCellFormula(null);
  }		
  test.writeBook("result_" + file);
}
Comment 1 PJ Fanning 2021-11-27 10:20:01 UTC
POI V5.1.0 has fixes for shared formulas. Reopen this if they do not help.