[apache poi xssf]:creating pivot table in new sheet(Java)
<p>I've modified the basic <a href="http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java" rel="nofollow">example</a> to create a pivot table in a new worksheet. But upon opening the new xlsx file, I get an error (<code>Excel found unreadable content in...</code>followed by: </p>

<pre><code>Removed Part: /xl/pivotTables/pivotTable1.xml part with XML error.  (PivotTable view) Load error. Line 2, column 561.
Removed Records: Workbook properties from /xl/workbook.xml part (Workbook)
</code></pre>

<p>)</p>

<p>Here's the code snippet I modified:</p>

<pre><code>XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("plain");

//Create some data to build the pivot table on
setCellData(sheet);

XSSFSheet sheet2 = wb.createSheet("pivot");

XSSFPivotTable pivotTable = sheet2.createPivotTable(new AreaReference("plain!$A$1:$D$4", null), new CellReference("pivot!$A$1"));
//Configure the pivot table
//Use first column as row label
pivotTable.addRowLabel(0);
//Sum up the second column
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
//Set the third column as filter
pivotTable.addColumnLabel(DataConsolidateFunction.AVERAGE, 2);
//Add filter on forth column
pivotTable.addReportFilter(3);
</code></pre>

<p>I've debugged through the code, and don't see an apparent issue...</p>

<p>Thoughts on how this can be handled? or if this is a bug with the library?</p>

<p>Thanks</p>

<p><strong>EDIT</strong></p>

<p>The problem is with starting from cell reference A1 (<code>new CellReference("pivot!$A$1")</code>) in the above code. It seems, if we start from A1, there is not enough space left on the sheet to do some other formatting pivot grid does. So changing that to A5 does the work. Though I still think POI should explicitly prevent people from doing this by throwing an error</p>