Thread

Posted on Thu Oct 27 18:09:31 2005 by mlcohen
No thoughts on table headings?
Nobody has any ideas on what to do about my table heading problem? To repeat briefly, if you make a table in writer, the first row is considered to be a "Table Header Row". The column headings can't be accessed with the regular table access methods. The only difference in the xml is that the first row is surrounded by < table:table-header-rows> tags. I want to be able to read a table without knowing the ordering of the columns in advance and be able to figure out which two columns are the ones I'm interested in. Column name is not just a simple attribute like table:name, it's text. Any help would be very much appreciated.
Thanks,
Matt
Direct Responses: 1251 | Write a response
Posted on Fri Oct 28 05:55:55 2005 by bob in response to 1249
Re: No thoughts on table headings?
I'm not certain but this might not hurt more than it's going to help!

It looks like you can get to the header row, but I'm not certain how.

I have an Open Office document which has approximately a dozen tables.

if I use:
my @rows = $content->getTableRows($table);

and then look at the first element, $rows[0], in all cases, _but one_, it does not see the header row.

There is one table for which it returns the header row.
and that table seems to start off with a simpler table definition :

<table:table table:name="distribution" table:style-name="distribution"> <table:table-column table:number-columns-repeated="4" table:style-name="distributio\ n.A"/> <table:table-row> <table:table-cell table:style-name="distribution.A1" table:value-type="string"> <text:p text:style-name="Table Heading">To</text:p> </table:table-cell> <table:table-cell table:style-name="distribution.A1" table:value-type="string"> <text:p text:style-name="Table Heading">Address</text:p> </table:table-cell> <table:table-cell table:style-name="distribution.A1" table:value-type="string"> <text:p text:style-name="Table Heading">Fax</text:p> </table:table-cell> <table:table-cell table:style-name="distribution.D1" table:value-type="string"> <text:p text:style-name="Table Heading">Phone</text:p> </table:table-cell> </table:table-row> <table:table-row>
whereas the other is:
<table:table table:name="emg_le" table:style-name="emg_le"> <table:table-column table:style-name="emg_le.A"/> <table:table-column table:style-name="emg_le.B"/> <table:table-column table:style-name="emg_le.C"/> <table:table-column table:style-name="emg_le.D"/> <table:table-column table:style-name="emg_le.E"/> <table:table-column table:style-name="emg_le.F"/> <table:table-column table:style-name="emg_le.G"/> <table:table-column table:style-name="emg_le.H"/> <table:table-column table:style-name="emg_le.I"/> <table:table-header-rows> <table:table-row> <table:table-cell table:style-name="emg_le.A1" table:value-type="string"> <text:p text:style-name="P3">SIDE</text:p> </table:table-cell> <table:table-cell table:style-name="emg_le.B1" table:value-type="string"> <text:p text:style-name="P3">NERVE</text:p> </table:table-cell> <table:table-cell table:style-name="emg_le.B1" table:value-type="string"> <text:p text:style-name="P3">STUDY TYPE</text:p> </table:table-cell> <table:table-cell table:style-name="emg_le.B1" table:value-type="string"> <text:p text:style-name="P3">STIMULATION SITE</text:p> </table:table-cell>
I have no recollection of how I created the table that uses 'table-number-columns-repeated=4'

If you find out let me know. I'd like to be able to get to the header row for each table too.

Bob
Direct Responses: 1270 | Write a response
Posted on Mon Oct 31 18:29:26 2005 by jmgdoc in response to 1251
Re: No thoughts on table headings?

There will be a new getTableHeaderRow(table) in 2.014 (coming this week). It will be described in the OpenOffice::OODoc::Text manual page.
For a short term workaround with previous versions, see below.

Table row/cell access methods generally ignore the table header (if any) and work only with the table body. However, as usual, it's possible to navigate anywhere through the low level API.

Asuming $table is a table element (previously retrieved using getTable), you can get its header using the XML::Twig::Elt first_child method:
my $header = $table->first_child('table:table-header-rows'); my $row = $header->first_child('table:table-row') if $header;
After the sequence above, $row contains the first row of the table header; it can be used as an ordinary table row (for example to retrieve cells).
Direct Responses: 1271 | Write a response
Posted on Mon Oct 31 19:06:39 2005 by mlcohen in response to 1270
Re: No thoughts on table headings?
Thanks, that works perfectly. My designers will be very happy.
Matt
Write a response