You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2026/07/28 10:00:05 UTC
[Bug 68305] Invalid sheetIndex Error in formulaEvaluator.evaluate(cell) for Cell Formula with Escaped Apostrophe in Sheet Name
https://bz.apache.org/bugzilla/show_bug.cgi?id=68305
simon.kafader@dvbern.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
--- Comment #4 from simon.kafader@dvbern.ch ---
I could reproduce this with the following code
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
class PoiApostropheFormulaTest {
@Test
void
evaluateAll_shouldNotThrow_whenNameFormulaReferencesSheetWithApostrophe()
throws IOException {
try (Workbook workbook =
createWorkbookWithApostropheNameFormula()) {
FormulaEvaluator evaluator =
workbook.getCreationHelper().createFormulaEvaluator();
// This call throws IllegalArgumentException: Invalid
sheetIndex
evaluator.evaluateAll();
}
}
private static Workbook createWorkbookWithApostropheNameFormula() {
Workbook workbook = new XSSFWorkbook();
// Sheet name containing an apostrophe
Sheet dataSheet = workbook.createSheet("L'embrace");
dataSheet.createRow(0).createCell(0).setCellValue(42);
// Defined name pointing at the apostrophe sheet, correctly
escaped per Excel syntax
Name name = workbook.createName();
name.setNameName("myLocalName");
name.setRefersToFormula("'L''embrace'!$A$1");
name.setSheetIndex(workbook.getSheetIndex(dataSheet));
dataSheet.getRow(0).createCell(1).setCellFormula("myLocalName");
return workbook;
}
}
--
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