Bug 58064 - rename sheet error when sheet contains IFERROR function
Summary: rename sheet error when sheet contains IFERROR function
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.11-FINAL
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: APIBug, ErrorMessage
Depends on:
Blocks:
 
Reported: 2015-06-21 03:51 UTC by John Jiang
Modified: 2015-06-23 06:31 UTC (History)
0 users



Attachments
test iferror function on POI 3.11 when set new sheet name. (14.83 KB, application/octet-stream)
2015-06-23 06:22 UTC, John Jiang
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Jiang 2015-06-21 03:51:57 UTC
I want to rename a Excel Sheet, most of the time is ok, but yesterday I rename a sheet with IFERROR function, throw a NullPointException.
Comment 1 Dominik Stadler 2015-06-21 06:16:05 UTC
Can you provide details, i.e. a sample file and a piece of self-contained code which reproduces the problem?
Comment 2 John Jiang 2015-06-23 06:21:31 UTC
Test Excel(xlsx):
   New one Excel file on windows platform, open it, select Cell D4 and set cell value to "=IFERROR(VLOOKUP(C4,'Country List'!$A$1:$B$251,2,0),"")"(except outside ").
 'Country List' is a sheet, contains the conntry name list, col A full contry name, col B abbreviation.


Test Code: 
   @Test
    public void testRenameSheet() throws IOException, InvalidFormatException {
        String filePath = "D:\\win7temp\\testiferror.xlsx";
        Workbook book = WorkbookFactory.create(new File(filePath));
        Sheet sheet = book.getSheetAt(0);
        System.out.printf("origin name:%s \n", sheet.getSheetName());
        book.setSheetName(0, "NewSheetName");
        System.out.printf("rename over!");
    }

Output is:
origin name:Sheet1 

java.lang.NullPointerException
	at org.apache.poi.xssf.usermodel.helpers.XSSFFormulaUtils.updatePtg(XSSFFormulaUtils.java:128)
	at org.apache.poi.xssf.usermodel.helpers.XSSFFormulaUtils.updateFormula(XSSFFormulaUtils.java:98)
	at org.apache.poi.xssf.usermodel.helpers.XSSFFormulaUtils.updateSheetName(XSSFFormulaUtils.java:78)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.setSheetName(XSSFWorkbook.java:1361)
	at com.lrm.test.POICopyUtilTest.testRenameSheet(POICopyUtilTest.java:36)
Comment 3 John Jiang 2015-06-23 06:22:32 UTC
Created attachment 32851 [details]
test iferror function on POI 3.11 when set new sheet name.
Comment 4 John Jiang 2015-06-23 06:31:04 UTC
(In reply to Dominik Stadler from comment #1)
> Can you provide details, i.e. a sample file and a piece of self-contained
> code which reproduces the problem?

I test it on POI 3.12 is ok.