I can see several mistakes :
1)
The data for the sub-block should be a "recordset", that is an array of array.
In your snippet, you should replace:
"rawdata" => array(
"fecha"=>$ro['fecha'],
"stock_total"=>$ro['stock_total'],
"venta_unit"=>$ro['venta_unit'],
"venta_total"=>$ro['venta_total']
)
with:
"rawdata" => array(
array(
"fecha"=>$ro['fecha'],
"stock_total"=>$ro['stock_total'],
"venta_unit"=>$ro['venta_unit'],
"venta_total"=>$ro['venta_total'],
),
),
Thus the data structure is correct, but the sub block always have only one record. This is maybe not what you expect.
2)
The sub-block definition in the XLSX will not display 4 rows.
With OpenTBS, when you repeat "block=…" that produces alternative sections.
In order to have a sub-block defined on 4 rows you should write :
[p;block=begin;sub1=rawdata]
[p.ref]
[p.label]
[p.unidad]
[p_sub1.fecha;block=4*tbs:row] (this will define a block over 4 rows, including this one)
[p_sub1.stock_total]
[p_sub1.venta_unit]
[p_sub1.venta_total] (the last row of block 'p_sub1')
[p;block=end]
With XML templates such as Ms Officve or LibreOffice, it is not advised to define a block with the explict syntax (block=begin
… block=end
). This is because you cannot imaging where the XLM entities bounds are actually positioned.
And you need luck in order to have a valid XML result.
If you put a different color on each of you row in the template, then watch the color in the result. You’ll see that block=begin
has broken some rows in the middle.
The good practice with OpenTBS is to define block bounds with the relative syntax, such as block=tbs:row
.
I suggest you template should be :
[p;block=8*tbs:row;sub1=rawdata] (8 rows including the sub-block)
[p.ref]
[p.label]
[p.unidad]
[p_sub1.fecha;block=4*tbs:row] (this will define a block over 4 rows, including this one)
[p_sub1.stock_total]
[p_sub1.venta_unit]
[p_sub1.venta_total] (the last row of block 'p_sub1')