incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Asier <avsg...@gmail.com>
Subject Re: Copy table
Date Mon, 07 May 2012 16:41:39 GMT
El 04/05/2012 13:00, Devin Han escribió:

Thanks, it works very well.

I've needed to copy some functions from SpreadSheetDocument (updateNames and
updateXMLId) due package visibility and now the table gets appended to the
document.

Regards

> TableTableElement newTableEle = (TableTableElement)
> (st.getOdfElement().cloneNode(true));
> final Table newTable =
> getTableBuilder().getTableInstance((TableTableElement) newTableEle);
> 
> you can reference : public Table appendSheet(Table refTable, String name)
> in SpreadsheetDocument.java
> 
> 2012/4/26 Asier CD. <avsgi09@gmail.com>
> 
>> Hi
>>
>> I'm creating a documento which must have some simple tables - a detail
>> list, 2 columns, undetermined number of rows- so I've created a
>> template file with an empty table (with some formatting) so the idea
>> is to copy the empty table, set it's name and add the rows, but I
>> don't know how to copy a table.
>>
>> I'm using odftoolkit.simple
>>
>> public void fill(TextDocument doc, List<SpecDetail> specs) {
>>     final Table st =
>> doc.getTableByName(OfferDocumentGenerator.OFFER_SPEC_TABLE);
>>
>>    // Copy table - how to do it?
>>   // final Table newTable =
>>
>>   // Fill table
>>   for (SpecDetail specDetail : specs) {
>>     newTable.setName(specDetail.getName());
>>     for (DetailLine line : specDetail.lines() {
>>        this.addRow(newTable, line.getKey(), line.getValue());
>>     }
>>   }
>>
>>  // Remove the table
>>  doc.removeElementLinkedResource(st.getOdfElement());
>>
>>
>> Regards
>>
> 
> 
> 


Mime
View raw message