OpenTBS - excel模板中动态行数,列生成策略(用于图表数据)

I am using OpenTBS to generate a dynamic number of rows and columns for generating an m x n matrix. I need to specify a non static number of rows, and columns for the data source.

How do I go about generating a dynamic number of columns and rows (m x n) in a template for OpenTBS to use as data source into a chart?

Is this possible, are there workarounds, or does this require some other tool other than OpenTBS?

Update - Embedded Excel Template

+-----------------+------------------------------------------+
|                 |  [c.key;block=td;parallel=tbs:table]     |
+-----------------+------------------------------------------+
|  [r.$;block=tr] |  [r.[c.val;block=td]]                    |
+-----------------+------------------------------------------+

PHP Code

// -----------------
// Output the result
// -----------------
$nbr_row = 5;
$nbr_col = 5;
// List of column's names
$columns = array();
for ($col=1; $col <= $nbr_col; $col++)
{
    $columns[$col]=  $col;
}





$data = array();
for ($row=0; $row<=$nbr_row; $row++)
{
    $record = array();
    if ($row == 0)
    {
        for ($col=1; $col <= $nbr_col; $col++)
        {
            $record[$columns[$col]] = $col;
        }
    }
    for ($col=1; $col <= $nbr_col; $col++)
    {
        $record[$columns[$col]] = 1;
    }
    $data[$row] = $record;
}

// Expanding columns
$TBS->MergeBlock('c',$columns);

// Merging rows
$TBS->MergeBlock('r',$data);
$TBS->Show();

Dynamic number of row is very simple with OpenTBS. For an XLSX template, you just have to use a MergeBlock() on a block defined with block=tbs:row.

Dynamic number of columns is more difficult to manage for an XLSX. It's difficult but not impossible. You can use the technical of merging columns and then rows as for an HTML table. But this technical assumes that you know the actual number of rows (I mean in the inner XML) in the spreadsheet before to merge columns and rows. And that is the difficult point because when you edit an XLSX template with Ms Excel, you don't really see what are the actual columns and rows saved in the inner XML. Fortunately, you can use the shortcut [Ctrl][End], that will select the last actual cell in the current worksheet.

How to use the merged result into a chart is another point that deserves another Stackoverflow question because it depends of what you're trying to do.