<action dev="POI-DEVELOPERS" type="fix">46643 - Fixed formula parser to encode range operator with tMemFunc</action>
<action dev="POI-DEVELOPERS" type="fix">46647 - Fixed COUNTIF NE operator and other special cases involving type conversion</action>
<action dev="POI-DEVELOPERS" type="add">46635 - Added a method to remove slides</action>
- <action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
+ <action dev="POI-DEVELOPERS" type="fix">40520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
<action dev="POI-DEVELOPERS" type="fix">46545 - Fixed ObjRecord to ignore excessive padding written by previous POI versions</action>
<action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action>
<action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>
<action dev="POI-DEVELOPERS" type="fix">46643 - Fixed formula parser to encode range operator with tMemFunc</action>
<action dev="POI-DEVELOPERS" type="fix">46647 - Fixed COUNTIF NE operator and other special cases involving type conversion</action>
<action dev="POI-DEVELOPERS" type="add">46635 - Added a method to remove slides</action>
- <action dev="POI-DEVELOPERS" type="fix">46520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
+ <action dev="POI-DEVELOPERS" type="fix">40520 - Fixed HSSFFont.applyFont() to properly apply font to overlapping regions</action>
<action dev="POI-DEVELOPERS" type="fix">46545 - Fixed ObjRecord to ignore excessive padding written by previous POI versions</action>
<action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action>
<action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action>
*/\r
public void updateNamedRanges(FormulaShifter shifter) {\r
XSSFWorkbook wb = sheet.getWorkbook();\r
- int sheetIndex = wb.getSheetIndex(sheet);\r
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);\r
for (int i = 0; i < wb.getNumberOfNames(); i++) {\r
XSSFName name = wb.getNameAt(i);\r
String formula = name.getRefersToFormula();\r
+ int sheetIndex = name.getSheetIndex();\r
\r
Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.NAMEDRANGE, sheetIndex);\r
if (shifter.adjustFormula(ptgs, sheetIndex)) {\r
\r
public final void baseTestShiftWithNames() {\r
Workbook wb = getTestDataProvider().createWorkbook();\r
- Sheet sheet = wb.createSheet();\r
- Row row = sheet.createRow(0);\r
+ Sheet sheet1 = wb.createSheet("Sheet1");\r
+ Sheet sheet2 = wb.createSheet("Sheet2");\r
+ Row row = sheet1.createRow(0);\r
row.createCell(0).setCellValue(1.1);\r
row.createCell(1).setCellValue(2.2);\r
\r
Name name1 = wb.createName();\r
name1.setNameName("name1");\r
- name1.setRefersToFormula("A1+B1");\r
+ name1.setRefersToFormula("Sheet1!$A$1+Sheet1!$B$1");\r
\r
Name name2 = wb.createName();\r
name2.setNameName("name2");\r
- name2.setRefersToFormula("A1");\r
+ name2.setRefersToFormula("Sheet1!$A$1");\r
\r
- sheet.shiftRows(0, 1, 2);\r
+ //refers to A1 but on Sheet2. Should stay unaffected.\r
+ Name name3 = wb.createName();\r
+ name3.setNameName("name3");\r
+ name3.setRefersToFormula("Sheet2!$A$1");\r
+\r
+ //The scope of this one is Sheet2. Should stay unaffected.\r
+ Name name4 = wb.createName();\r
+ name4.setNameName("name4");\r
+ name4.setRefersToFormula("A1");\r
+ name4.setSheetIndex(1);\r
+\r
+ sheet1.shiftRows(0, 1, 2); //shift down the top row on Sheet1.\r
name1 = wb.getNameAt(0);\r
- assertEquals("A3+B3", name1.getRefersToFormula());\r
+ assertEquals("Sheet1!$A$3+Sheet1!$B$3", name1.getRefersToFormula());\r
\r
name2 = wb.getNameAt(1);\r
- assertEquals("A3", name2.getRefersToFormula()); \r
+ assertEquals("Sheet1!$A$3", name2.getRefersToFormula()); \r
+\r
+ //name3 and name4 refer to Sheet2 and should not be affected\r
+ name3 = wb.getNameAt(2);\r
+ assertEquals("Sheet2!$A$1", name3.getRefersToFormula());\r
+\r
+ name4 = wb.getNameAt(3);\r
+ assertEquals("A1", name4.getRefersToFormula());\r
}\r
\r
public final void baseTestShiftWithMergedRegions() {\r