https://issues.apache.org/bugzilla/show_bug.cgi?id=47100
Carl Pritchett <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] Version|3.5-dev |3.7 --- Comment #1 from Carl Pritchett <[email protected]> 2011-02-27 22:46:19 EST --- Hi, When I create a HSSFWorkbook with a named range and then set the sheet name with Workbook.setSheetName() all the named ranges' formulas are renamed also. When I do this with a XSSFWorkbook the named ranges' formulas are not renamed and thus are broken (have the value of #REF!"). Here is a JUnit test that creates a file with such a broken named range. @Test public void create() throws IOException { String sname = "TestSheet", cname = "TestName", cvalue = "TestVal"; // HSSFWorkbook handles rename // Workbook wb = new HSSFWorkbook(); //File file = new File("c:\\test.xls"); // XSSFWorkbook does not handle the rename Workbook wb = new XSSFWorkbook(); File file = new File("c:\\test.xlsx"); Sheet sheet = wb.createSheet(sname); sheet.createRow(0).createCell((short) 0).setCellValue(cvalue); // 1. create named range for a single cell using areareference Name namedCell = wb.createName(); namedCell.setNameName(cname); String reference = sname+"!A1:A1"; // area reference namedCell.setRefersToFormula(reference); // 2. rename the sheet wb.setSheetName(wb.getSheetIndex(sheet), "newName"); FileOutputStream fout = new FileOutputStream(file); wb.write(fout); } Any workarounds? Regards, Carl Pritchett -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
