https://bz.apache.org/bugzilla/show_bug.cgi?id=60811

--- Comment #4 from Greg Woolsey <gwool...@apache.org> ---
I have a rather large class that does pretty much what you are wanting, that I
use for my day job.  It digs into the XSSFTable for the related CTConnection,
uses that to query the database, and updates the table definition with the new
results, wiping out previous rows.

I combine the 

CTQueryTableFields.getQueryTableFieldList() 
and the 
CTTable.getTableColumns().getTableColumnList()

by index into a composite object that tracks the column definitions.  For
calculated columns, that don't come from the query results, I just set the cell
formula to:

CTTableColumn.getCalculatedColumnFormula().getStringValue()

which works for me just fine in all my tests so far.  I've not had to do any
manual adjusting of formulas, but I don't know that I've tried any with
references that weren't already in structured query format.

If the table isn't an actual table, but just a formatted range of cells, then
you will have to write your own handling.  But this works for me for QueryTable
updates, which is a key part of my company's product.

I've thought about making this part of POI, but haven't had the time or
inclination to figure out what a reasonable API would be.  Currently I use
ResultSet.next() and ResultSet.getObject(CTQueryTableField.getName()) to match
things up.  I suppose I could write an Interface that encapsulated them, with
some checked exceptions for missing/invalid column names in the input vs. the
table definition.

Doesn't do anything for reversing formula evaluation, but does handle
QueryTable updates.

That should be enough details to point you in the right direction if you want
to take a crack at it.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to