There is already a method, updateHeaders(), that resets most of the instance computed/cached fields, but it doesn't unset the lazily evaluated start and end cell references for the Table. If you want to add or remove rows from a table definition, you need to change the underlying CTTable object, and reset these cached values in the XSSFTable wrapper. Currently, the only way to hack this is to use reflection to get at the private fields, which is not how we want to do it. The easy fix is to just add: public void updateReferences() { startCellReference = null; endCellReference = null; } The next time they are requested, they are re-computed from the underlying (possibly updated) CTTable. It is still up to the user to ensure the CTTable references match the data in the worksheet. I think this should be its own method, rather than just adding the two lines to updateHeaders(), as there are distinct use cases for changing the headers of a table and just adding/removing rows from a table. No need to incur the overhead of recomputing one when only the other is changing.
Applied in r1751368 with a corresponding unit test and updated documentation. I noticed that getRowCount returns toRow-fromRow. Shouldn't it be toRow-fromRow+1?
(In reply to Javen O'Neal from comment #1) > Applied in r1751368 with a corresponding unit test and updated documentation. > > I noticed that getRowCount returns toRow-fromRow. Shouldn't it be > toRow-fromRow+1? Good catch, yes, I think it should. Thanks for the quick turn around! (on a US holiday, no less - if that's where you are). Doesn't look like many people are using Tables yet in XSSF workbooks - maybe because the formula syntax didn't work until the recent flurry of changes we made.
(In reply to Javen O'Neal from comment #1) > I noticed that getRowCount returns toRow-fromRow. Shouldn't it be > toRow-fromRow+1? Spun off getRowCount fix to bug 59796 > (on a US holiday, no less - if that's where you are). 2 hour road trip was a perfect opportunity to get these fixes in. I'm glad to have an XSSFTable expert to help this class mature (hoping to make getCTTable protected in the future).
(In reply to Javen O'Neal from comment #3) > (hoping to make getCTTable protected in the future). That will require some more code. Right now I'm trying to figure out how to get the QueryTable related to a Table, so I can get the Connection for the QueryTable and then eventually have Java perform queries previously done by ODBC/ADO (that will be custom code, not part of POI, but the document object links are arcane and not documented). Learning about the OPCPackage, PackagePart, and POIXMLDocumentPart classes.