Hello all.
I've asked this question before and it seems that a lot of the Excel
functionality for tables and subtotal rows is not fully functional in POI. At
the time I was using 3.9. I recently turned back to this project and upgraded
to the most recent stable POI release of 3.14. The same problems still exist.
If relevant I'm using Eclipse Mars and 64 bit Oracle JDK 8 build 91.
When I save the spreadsheet it always gives me this in the sheet1.xml document
in the archive for the cell that I set up to be the column total:
<c r="D5"/>
If I open it in Excel and then manually choose COUNT in the total row and save
it, the cell gets changed to this:
<c r="D5">
<f>SUBTOTAL(103,MyTable[MyColumn])</f>
<v>3</v>
</c>
The table1.xml document contains the following markup before and after, so I
believe this much is correct:
<tableColumn id="4" name="Human" totalsRowFunction="count"/>
Is it possible to insert my own XML into the DOM model? I've tried something
like this:
CTTableColumn column = columns.addNewTableColumn();
column.setTotalsRowFunction(STTotalsRowFunctionImpl.COUNT); //
I would expect this to be the only step necessary, except maybe a call to
evaluateAllFormulaCells (which I do)
/* the next three lines add the proper dom fragment to mimic
the above Excel-saved version, but the markup isn't there in the saved
spreadsheet */
Element f =
column.getDomNode().getOwnerDocument().createElement("f");
f.appendChild(column.getDomNode().getOwnerDocument().createTextNode("SUBTOTAL(103,MyTable[MyColumn])"));
column.getDomNode().appendChild(f);
When I inspect the element it does show up as I expect, but on saving the
spreadsheet and opening the archive the inserted element is gone. If anyone can
give me a pointer I'd appreciate it.
John