TinyButStrong - the PHP Template Engine
Categories > OpenTBS general LibreOffice >

newbie: block merge in table with colspans - using openTbs - open office plugin

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: william
Date: 2010-06-20
Time: 16:29

newbie: block merge in table with colspans - using openTbs - open office plugin

I want to merge from a php array into a table, but I want to use some table formatting and can not figure out how.
The basic format of the table is:
col1  col2 col3 col4 col5 col6
but there are summary rows that have col7 and cols1-6 are merged into 1 wide column with a colspan="6". 

I can't figure out how to write the template to do this
By: Skrol29
Date: 2010-06-20
Time: 17:37

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

Hi,

What is the kind of OpenOffice document you want to have this table?
By: william
Date: 2010-06-20
Time: 20:43

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

I want the document to be a writer document.
By: Skrol29
Date: 2010-06-20
Time: 21:23

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

Hi,

Just use OpenOffice to do the formatting.
A demo set is given with the OpenTbs package, including a Writer document which is used to merge data with a writer table.

There is no problem to design then spanned columns with OpenOffice, but 
are those summary rows involved with the data?
If it's so, please tell us how they are involved, so we can help you with that.
By: william
Date: 2010-06-21
Time: 11:50

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

The data is generated from a php script. The table consists of n rows of charge or payment data.  At each change of month I insert a month total row that is one cell wider than the rest of the table.  The charge/payment rows are 6 columns wide and they are (in html) colspaned with right-aligned text that says: Total for mm/yyyy.  Thus the total charge/payment sticks out from the right side of the table for easy visibility.

I can't use OO to do the formatting as I do not know in advance how many charge/payment rows there will be for each month or how many months will be in the report.

Thanks for the assistance,
Bill
By: william
Date: 2010-06-21
Time: 12:17

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

BTW, I have no objection to defining the table in OO with an extra column and making it blank for all charge/payment rows.  I do. unfortunately need the spanned cells though.  I looked up the XML for the way OO defines spanned cells and could write it, but would prefer to avoid that as it gets a bit low level for the rest of the table.

bill
By: Skrol29
Date: 2010-06-21
Time: 13:57

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

Hi,

If I understand, your data are stored in a PHP array, including normal rows and monthly total rows.

You can design the corresponding template directly in OpenOffice. You can also do in the XML, but to tell what to do in the XML I would do it first in OO and then I read the XML. So now, I just tell you the design directly in OO.

In OpenOffice:
-----------------
- Design your table with the header row, the detail row (charge or payment) and the monthly total row.
- Span the cols you need on the monthly total row.
- Now you will define the block to merge and give it 2 conditional sections: one section for the monthly total records, and one section for the detail records. Let's name your block "b1". And we assume that your PHP data contains a column named "type" which is "t" when the record is a monthly total, and "d" when the record is a detail (charge or payment).
- On the monthly total row, add in a cell:
   [b1.amount;block=table:table-row;when [b1.type]=t]]
- On the normal row, add in a cell:
   [b1.amount;block=table:table-row;default]

The merge the block using a simple
  $TBS->MergeBlock('b1', $data);
or
  $TBS->MergeBlock('b1', 'array', $data);

By the way, if your data did not include the total rows, you could make them directly in the template with a "footergrp" section. You would also need the aggregate plugin to calculate the totals.
By: william
Date: 2010-06-21
Time: 15:13

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

Clever, thank you very much, let me digest this.
By: william
Date: 2010-06-21
Time: 15:19

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

Can this be generalized further?
I need to use the header row for a real header (that repeats on each page).

From my limited knowledge of OO and TBS and your reply, I do not see how the reply needs to use the header.  Can I just use the conditional on two "normal" rows ?

bill
By: william
Date: 2010-06-21
Time: 15:28

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

About using footergrp:
Just to verify: there is no displayed column with the month in it.  There is a displayed column with the posting date in it, from which I extract the month to decide when to have a subtotal.  I can easily add a column with the extracted date. Can a footergrp be triggered by a non-displayed column in the data ?

Thanks again and very much.

bill
By: Skrol29
Date: 2010-06-21
Time: 16:02

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

Hi,

>Can this be generalized further?

Yes

> I need to use the header row for a real header (that repeats on each page).

Let OpenOffice manage this. Just check that the option "repeat title" is enabled on the table property. It it usually enabled by default.

>About using footergrp: Just to verify: there is no displayed column with the month in it. There is
> a displayed column with the posting date in it, from which I extract the month to decide
> when to have a subtotal.  I can easily add a column with the extracted date. Can a
> footergrp be triggered by a non-displayed column in the data ?

Yes of course. Use parameter "footergrp" like this:
  footergrp=column1
column1 must exists in the data, but if you don't use it as a viewable field in the template, it won't be shown. 
See the inline examples here (search example "grouping"):
  http://www.tinybutstrong.com/examples.php
It is exactly the same think with OpenOffice.
By: william
Date: 2010-06-21
Time: 16:43

Re: newbie: block merge in table with colspans - using openTbs - open office plugin

works marvelously.

merci beaucoup !

bill