https://bz.apache.org/bugzilla/show_bug.cgi?id=57929
Javen O'Neal <one...@apache.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO --- Comment #1 from Javen O'Neal <one...@apache.org> --- Thanks for the simple test case. I added this to our test suite in r I have verified the behavior your observed using an HSSFWorkbook. This problem does not occur on XSSFWorkbooks or SXSSFWorkbooks. If this bug is still relevant to you, you could try to dive through the code in HSSFWorkbook/InternalWorkbook to figure out what's going on. It is possible that the Excel 97-2003 format doesn't allow null print areas, instead using some default print area. Here's what I tried: HSSFWorkbook: > public void removePrintArea(int sheetIndex) { >+ // Clear out the formula tokens (equivalent to making this reference >null) >+ NameRecord name = >workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1); >+ name.setNameDefinition(new Ptg[] {}); >+ > getWorkbook().removeBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, > sheetIndex+1); > } got: > ptgs must not be null > java.lang.IllegalArgumentException: ptgs must not be null > at > org.apache.poi.ss.formula.FormulaRenderer.toFormulaString(FormulaRenderer.java:48) > at > org.apache.poi.hssf.model.HSSFFormulaParser.toFormulaString(HSSFFormulaParser.java:81) > at > org.apache.poi.hssf.usermodel.HSSFWorkbook.getPrintArea(HSSFWorkbook.java:1547) > at > org.apache.poi.ss.usermodel.BaseTestBugzillaIssues.test57929(BaseTestBugzillaIssues.java:1605) HSSFWorkbook: > ... >+ name.setNameDefinition(HSSFFormulaParser.parse("", this, >FormulaType.NAMEDRANGE, sheetIndex)); > ... got: > Parse error near char 0 '' in specified formula ''. Expected cell ref or > constant literal > org.apache.poi.ss.formula.FormulaParseException: Parse error near char 0 '' > in specified formula ''. Expected cell ref or constant literal HSSFWorkbook: > ... >+ >name.setNameDefinition(HSSFFormulaParser.parse("'"+getSheetName(0)+"'!$A$1:$A$1", > this, FormulaType.NAMEDRANGE, sheetIndex)); > ... got: > Sheet0 after write expected null, but was:<Sheet0!$A$1:$A$1> > junit.framework.AssertionFailedError: Sheet0 after write expected null, but > was:<Sheet0!$A$1:$A$1> > at > org.apache.poi.ss.usermodel.BaseTestBugzillaIssues.test57929(BaseTestBugzillaIssues.java:1605 HSSFWorkbook > ... >+ name.setNameDefinition(new Ptg[] { new Area3DPtg(-1, -1, -1, -1, false, >false, false, false, sheetIndex) }); > ... got: > Sheet0 after write expected null, but was:<Sheet0!$XFD$65536:$XFD$65536> > junit.framework.AssertionFailedError: Sheet0 after write expected null, but > was:<Sheet0!$XFD$65536:$XFD$65536> To fix this, someone needs to figure out how Excel stores records in the binary format to indicate no print area has been set, if it falls back to something like A1:lastCol/lastRow), or picks a print area based on the current page size and the width of the columns/height of the rows. -- 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