Categories > OpenTBS with DOCX >

OpenTBS - Sub-block and row

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: christophe
Date: 2013-07-10
Time: 12:38

OpenTBS - Sub-block and row

Hello,

I'm trying to generate a docx with openTBS but i'm running into problem with sub-block

my docx template is containing something like:

TITLE: 1    [ASB.TEAM;BLOCK=TBS:PAGE;SUB1=MATCHES]
then just under in a word array:
[asb_sub1.town;block=tbs:row]

My php code:

$TeamList[0] = array('team'=>'Eagle'  ,'total'=>'458');
$TeamList[0]['matches'][] = array('town'=>'London','score'=>'253','date'=>'1999-11-30');
$TeamList[0]['matches'][] = array('town'=>'Paris' ,'score'=>'145','date'=>'2002-07-24');
$TeamList[1] = array('team'=>'Goonies','total'=>'281');
$TeamList[1]['matches'][] = array('town'=>'New-York','score'=>'365','date'=>'2001-12-25');
$TeamList[1]['matches'][] = array('town'=>'Madrid'  ,'score'=>'521','date'=>'2004-01-14');
$TeamList[2] = array('team'=>'MIB'    ,'total'=>'615');
$TeamList[2]['matches'][] = array('town'=>'Dallas'    ,'score'=>'362','date'=>'2001-01-02');
$TeamList[2]['matches'][] = array('town'=>'Lyon'      ,'score'=>'321','date'=>'2002-11-17');
$TeamList[2]['matches'][] = array('town'=>'Washington','score'=>'245','date'=>'2003-08-24');

$TBS->LoadTemplate($template);
$TBS->MergeBlock('asb',$TeamList);

$TBS->PlugIn(OPENTBS_DELETE_COMMENTS);


// -----------------
// Output the result
// -----------------

// Define the name of the output file
$save_as = (isset($_POST['save_as']) && (trim($_POST['save_as'])!=='') && ($_SERVER['SERVER_NAME']=='localhost')) ? trim($_POST['save_as']) : '';
$output_file_name = str_replace('.', '_'.date('Y-m-d').$save_as.'.', $template);
if ($save_as==='') {
    // Output the result as a downloadable file (only streaming, no data saved in the server)
    $TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields.
} else {
    // Output the result as a file on the server
    $TBS->Show(OPENTBS_FILE+TBS_EXIT, $output_file_name); // Also merges all [onshow] automatic fields.
}


But at generation, i've an error message that the word document is not correctly formed (error from word itself)

Did you have any idea?
Christophe
By: Skrol29
Date: 2013-07-10
Time: 17:00

Re: OpenTBS - Sub-block and row

The first thing I can see is that TBS parameters are case sensitive.
So the field [ASB.TEAM;BLOCK=TBS:PAGE;SUB1=MATCHES] won't work as you expect.
By: christophe
Date: 2013-07-10
Time: 17:27

Re: OpenTBS - Sub-block and row

Yes, sorry, the title as defined in the top is formated in word as uppercase.
Without the word array everything is ok, when a add a simple (even empty ) array, i've errors.

Christophe
By: Skrol29
Date: 2013-07-11
Time: 01:07

Re: OpenTBS - Sub-block and row

Hi,

I cannot see what is wrong.
Did you tried without download, only generating the file ?
Did you tried the debug mode ?
By: christophe
Date: 2013-07-11
Time: 09:23

Re: OpenTBS - Sub-block and row

Yes tried with the xml generation, don't have any error at generation.
Seems to be a bug in OpenTBS with subblock and array.

without the array and with a tbs:p everything is ok, but when i change it to tbs:row then i've the problem.

C
By: Skrol29
Date: 2013-07-12
Time: 00:02

Re: OpenTBS - Sub-block and row

I need to see the template, is it possible for you to send it ?
The table may not be as you expect.
By: Skrol29
Date: 2013-07-13
Time: 00:51

Re: OpenTBS - Sub-block and row

Hi Christophe,

Thank you very much for the file you sent to me.
There was a bug in OpenTBS but not about the sub-template.
It was about parameter "block=tbs:page" when the last paragraph of the document has no text (strange isn't it ?).

The bug is now fixed in the last beta which can be downloaded here:
http://www.tinybutstrong.com/dl.php?f=tbs_plugin_opentbs_beta.zip&s=2

Regards,
By: christophe
Date: 2013-07-15
Time: 09:39

Re: OpenTBS - Sub-block and row

Thanks skrol29,

Did you have the content of the beta (changelog) to see the impact for production?

Christophe
By: Skrol29
Date: 2013-07-17
Time: 14:38

Re: OpenTBS - Sub-block and row

Hi,

The change-log in described in the documentation given with the package of the beta version.

Change-log for OpenTBS 1.8.1-beta, 2013-07-14

*    new feature: the loaded template can be a PHP file handle.
*    enhancement: Ms Excel Sheets are now saved with explicit references for rows and cells, so merged templates are viewable with Libre Office and other third viewers.
*    enhancement: keywords for changing cell types is the same for LibreOffice and Ms Office.
*    fixed bug: A DOCX file could be corrupted when using "block=tbs:page" and the last paragraph of the document has no text.
*    based on TbsZip 2.14