Author: gwoolsey
Date: Fri Feb 23 23:37:04 2018
New Revision: 1825182

URL: http://svn.apache.org/viewvc?rev=1825182&view=rev
Log:
The table auto-filter range should not include table footer rows, while the 
table range does.  POI was using the same for both regardless of footers.

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java?rev=1825182&r1=1825181&r2=1825182&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java Fri 
Feb 23 23:37:04 2018
@@ -350,6 +350,7 @@ public class XSSFTable extends POIXMLDoc
      * Updates the reference for the cells of the table
      * (see Open Office XML Part 4: chapter 3.5.1.2, attribute ref)
      * and synchronizes any changes
+     * @param refs table range
      * 
      * @since 3.17 beta 1
      */
@@ -363,7 +364,18 @@ public class XSSFTable extends POIXMLDoc
         // Update
         ctTable.setRef(ref);
         if (ctTable.isSetAutoFilter()) {
-            ctTable.getAutoFilter().setRef(ref);
+            String filterRef;
+            int totalsRowCount = getTotalsRowCount();
+            if (totalsRowCount == 0) {
+                filterRef = ref;
+            } else {
+                final CellReference start = new 
CellReference(refs.getFirstCell().getRow(), refs.getFirstCell().getCol());
+                // account for footer row(s) in auto-filter range, which 
doesn't include footers
+                final CellReference end = new 
CellReference(refs.getLastCell().getRow() - totalsRowCount, 
refs.getLastCell().getCol());
+                // this won't have sheet references because we built the cell 
references without them
+                filterRef = new AreaReference(start, end, 
SpreadsheetVersion.EXCEL2007).formatAsString();
+            }
+            ctTable.getAutoFilter().setRef(filterRef);
         }
         
         // Have everything recomputed
@@ -476,7 +488,7 @@ public class XSSFTable extends POIXMLDoc
 
         if (row != null && row.getCTRow().validate()) {
             int cellnum = firstHeaderColumn;
-            for (CTTableColumn col : 
getCTTable().getTableColumns().getTableColumnArray()) {
+            for (CTTableColumn col : 
getCTTable().getTableColumns().getTableColumnList()) {
                 XSSFCell cell = row.getCell(cellnum);
                 if (cell != null) {
                     col.setName(formatter.formatCellValue(cell));



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to