I've been trying to use POI 3.17 to generate files with Excel Tables (e.g. 
XSSFTable table = sheet.createTable()) over cells with merged ranges.  The file 
generates fine, but when opening it in Excel 2013, it shows a "we found a 
problem with some content..." error.  Upon trying to recover, it results in 
"Removed Feature: Table from /xl/tables/table1.xml part (Table)"

I've checked out  the 3.17 final:

| URL: https://svn.apache.org/repos/asf/poi/tags/REL_3_17_FINAL
| Relative URL: ^/poi/tags/REL_3_17_FINAL
| Repository Root: https://svn.apache.org/repos/asf
| Repository UUID: 13f79535-47bb-0310-9956-ffa450edef68
| Revision: 1830359

And from that I modified the CreateTable.java to add a row, add cells with 
MergedRegions to that row, and then extended the AreaReference on the XSSFTable 
to encompass the cells with MergedRegions.  Without the MergedRegions the 
example opens fine in Excel, but with them I get the error.

So, does anyone have any suggestions or examples of adding XSSFTables over 
MergedRegions?

Thanks,
Ryan Hayward


Here's the modifications I made to CreateTable.java in case I'm adding the 
MergedRegions in the wrong way, or something:

Index: src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateTable.java
===================================================================
--- src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateTable.java    
(revision 1830359)
+++ src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateTable.java    
(working copy)
@@ -21,6 +21,7 @@

 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -74,6 +75,23 @@
                 }
             }
         }
+
+       row = sheet.createRow(3);
+
+        for(int i=0; i<3; i++) {
+               cell = row.createCell(i);
+                cell.setCellValue((i+1)*4);
+
+               int additionalRows = 1;
+               int additionalColumns = 0;
+               cell.getSheet().addMergedRegion(
+                       new CellRangeAddress(
+                               cell.getRow().getRowNum(), 
cell.getRow().getRowNum()+additionalRows,
+                               cell.getColumnIndex(), 
cell.getColumnIndex()+additionalColumns
+                       )
+               );
+       }
+
         // Create the columns
         table.addColumn();
         table.addColumn();
@@ -81,7 +99,7 @@

         // Set which area the table should be placed in
         AreaReference reference = wb.getCreationHelper().createAreaReference(
-                new CellReference(0, 0), new CellReference(2, 2));
+                new CellReference(0, 0), new CellReference(4, 2));
         table.setCellReferences(reference);

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

Reply via email to