Categories > [old] TbsOoo & TinyDoc >

columns from array

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SunWuKung
Date: 2006-05-22
Time: 23:39

columns from array

Is it possible to create a table with TBS where not only the number of rows are dependent on the array, but also the number of columns?

eg. I create a pivot table with PHP from a db - I don't know beforehand the number of columns and the number of rows, still I would like to print this table, is it possible?

thx
SWK
By: Olivier Loynet
Date: 2006-05-23
Time: 09:30

Re: columns from array

It's possible to do only in spreadsheet files (SXC or ODS).
See the example
http://www.tinybutstrong.com/apps/tbsooo/example/tbsooo_us_examples_datanum.php

Olivier
By: SunWuKung
Date: 2006-05-23
Time: 21:53

Re: columns from array

I am out of luck here then - I work with Writer.
There is no way to do it in writer?
Maybe with two blocks - the first creating the columns the second the rows?

thx.
SWK
By: Olivier Loynet
Date: 2006-05-24
Time: 10:10

Re: columns from array

The problem is,  the numbers of columns are fixed when you prepare the template in the writer. In the spredsheet (calc), the table has many columns  pre allocate.

Olivier
By: nathangray
Date: 2007-03-19
Time: 20:27

Re: columns from array

I'm trying to do this, but I can only do rows or columns, not both.


If I have the columns
[stock.stock_num;block=table:table-row;headergrp=stock_id]
[stock.quantity_in_stock;block=table:table-cell;]

I get one row per stock item. 

If I use:
[stock.stock_num;block=table:table-row]
[stock.quantity_in_stock;block=table:table-cell;]

I get one row per array entry.

I'm trying to get one row per stock item, and one column per location.

Does anyone know the magic combination to do this?

My data looks like this:

Array
(
    [stock] => Array
        (
            [0] => Array
                (
                    [stock_id] => 141
                    [stock_num] => 05-00141
                    [short_description] => 1/4 HP Pump A
                    [location_id] => 6
                    [location_name] => Paint Shop
                    [quantity_in_stock] => 0.000
                )

            [1] => Array
                (
                    [stock_id] => 141
                    [stock_num] => 05-00141
                    [short_description] => 1/4 HP Pump A
                    [location_id] => 1
                    [location_name] => Main Plant
                    [quantity_in_stock] => 260.000
                )

            [2] => Array
                (
                    [stock_id] => 141
                    [stock_num] => 05-00141
                    [short_description] => 1/4 HP Pump A
                    [location_id] => 14
                    [location_name] => Row 1
                    [quantity_in_stock] => 0.000
                )

            [3] => Array
                (
                    [stock_id] => 3
                    [stock_num] => 15-00003
                    [short_description] => COMMON WIDGIT
                    [location_id] =>
                    [location_name] =>
                    [quantity_in_stock] => -4.000
                )

            [4] => Array
                (
                    [stock_id] => 3
                    [stock_num] => 15-00003
                    [short_description] => COMMON WIDGIT
                    [location_id] => 6
                    [location_name] => Paint Shop
                    [quantity_in_stock] => 0.000
                )
        )
)

Thanks,
Nathan
By: nathangray
Date: 2007-03-20
Time: 18:41

Re: columns from array

The missing magic was defining the columns, then using them first:
[location0.location_name;block=table:table-cell;noerr] as the column heading and
[stock.stock_num;block=table:table-row;noerr] [stock.[location1.location_id;block=table:table-cell;noerr].quantity_in_stock] as the row data