diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index b5d60ad17..d0f4f0e64 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -36,6 +36,7 @@ + Support getting all the cells referenced by an AreaReference, not just the corner ones 43510 - Add support for named ranges in formulas, including non-contiguous named ranges 43937 - Add support for hiding and un-hiding sheets, and checking their current hidden status 44167 - Fix for non-contiguous named ranges diff --git a/src/documentation/content/xdocs/hssf/quick-guide.xml b/src/documentation/content/xdocs/hssf/quick-guide.xml index a7ca260c7..b2f729fed 100644 --- a/src/documentation/content/xdocs/hssf/quick-guide.xml +++ b/src/documentation/content/xdocs/hssf/quick-guide.xml @@ -1151,7 +1151,7 @@ Examples: // retrieve the cell at the named range and test its contents AreaReference aref = new AreaReference(aNamedCell.getReference()); - CellReference[] crefs = aref.getCells(); + CellReference[] crefs = aref.getAllReferencedCells(); for (int i=0; i<crefs.length; i++) { HSSFSheet s = wb.getSheet(crefs[i].getSheetName()); HSSFRow r = sheet.getRow(crefs[i].getRow()); @@ -1177,13 +1177,15 @@ Examples: // another for D12 to D14 AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getReference()); for (int i=0; i<arefs.length; i++) { + // Only get the corners of the Area + // (use arefs[i].getAllReferencedCells() to get all cells) CellReference[] crefs = arefs[i].getCells(); for (int j=0; j<crefs.length; j++) { // Check it turns into real stuff HSSFSheet s = wb.getSheet(crefs[j].getSheetName()); HSSFRow r = s.getRow(crefs[j].getRow()); HSSFCell c = r.getCell(crefs[j].getCol()); - // extract the cell contents based on cell type etc. + // Do something with this corner cell } } diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 58d6df9aa..f4d7c1b07 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,7 @@ + Support getting all the cells referenced by an AreaReference, not just the corner ones 43510 - Add support for named ranges in formulas, including non-contiguous named ranges 43937 - Add support for hiding and un-hiding sheets, and checking their current hidden status 44167 - Fix for non-contiguous named ranges diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index ba9ff72a7..b0d822286 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -1212,6 +1212,16 @@ public class HSSFSheet } if ( endRow == lastrow || endRow + n > lastrow ) lastrow = Math.min( endRow + n, 65535 ); if ( startRow == firstrow || startRow + n < firstrow ) firstrow = Math.max( startRow + n, 0 ); + + // Update any formulas on this sheet that point to + // rows which have been moved + + // Update any named ranges defined for this workbook + // that point to this sheet and had rows they reference + // moved + for(int i=0; i