Is there is any way to make TBS automaticly choose when cell need to be numeric (ope=xlsxNum)? Or is it posible to use if or when for ope?
Asked
Active
Viewed 302 times
0
-
Can you give details of the case you have? Why the cell should contains several type of data ? What kind of "if" to you wish for parameter ope? – Skrol29 May 30 '13 at 23:50
-
[DATA.name;block=c;if DATA.type=NUM;ope=xlsxNum] – user2068152 May 31 '13 at 05:06
1 Answers
0
Here is a tip and trick that should work.
The difficulty is that in case of MergeBlock, formating parameters such as "ope=xlsxNum" are processed before the data are injected. This is for performance consideration. So we are going to merge the data twice: one for preparing TBS fields for the formating, and a second one for actually injecting data using MergeField() instead of MergeBlock().
Here is an example of data as a PHP array:
$data = array(
array('name'=>"Nom", 'type'=>'STR', 'value'=>'Jack');
array('name'=>"Stock", 'type'=>'NUM', 'value'=>1305);
array('name'=>"Value", 'type'=>'NUM', 'value'=>1.5498888);
);
Put the follong snippet in the cell:
[b2.[b1.$;block=c].value;[b1.type;if '[val]'='NUM';then 'ope=xlsxNum'; else '']]
And at the PHP side:
$TBS->MergeBlock('b1', $data); // prepare TBS fields with corresponding formating
$TBS->MergeField('b2', $data); // merge TBS fields with corresponding data
After 'b1' is merged, the template becomes:
[b2.0.value;] | [b2.0.value;ope=xlsxNum] | [b2.0.value;ope=xlsxNum]
After 'b2' is merged, the template becomes:
Jack | 1305 | 1.5498888

Skrol29
- 5,402
- 1
- 20
- 25