TinyButStrong - the PHP Template Engine
Categories > OpenTBS with ODS >

Problem loading Spreadsheet ( ODS )

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Chris Kiraly
Date: 2012-07-23
Time: 16:19

Problem loading Spreadsheet ( ODS )

Hey All -

I created an ODS Template file to test this with ( I want to use this on a massive multi-page spreadsheet, but I figure I'll start with something simple. )
It's named testing.ods.

the file contains the following:
A1 : [onshow.x]
B1 : [a.val1]
C1 : the following function:  =if( left(a1,1) = "[", "", A1+B1 )
A2 : [onshow.y]
B2 : [a.val2]
C2 : the following function: =if( left(a2,1) = "[", "", A1+B1 )
A3 : the following function: =sum( a1:a2 )
B3 : the following function: =sum( b1:b2 )
C3 : the following function: =sum( c1:c2 )

the function stuff works fine ( if I put values in a1 - b2, the sums and if functions create the proper values ).

The problem happens when I get the result_testing.ods file, it doesn't open up in Calc, it tries to open up Math.  and its Blank.

I'm not sure if I'm doing something wrong in the TBS code, or if something is wrong with the testing.ods file itself.

here is the PHP code I'm testing with:


10 include_once($RootPath."/tbs/tbs_class.php");
11 include_once($RootPath."/tbs/plugins/tbs_plugin_opentbs.php");
12
13 $TBS = new clsTinyButStrong;
14 $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
15 //$TBS->SetOption( 'n', TBS_OUTPUT );
16
17 $template = $RootPath."/xl-forms/testing.ods";
18
19 $x = 5;
20 $y = 11;
21
22 $xl[0]['val1'] = 10;
23 $xl[0]['val2'] = 16;
24
25 $TBS->LoadTemplate($template);
26 $TBS->MergeBlock('a', $xl );
27
28 $file = str_replace( '.ods', '_'.date( 'Y-m-d' ).'.ods', $template );
29
30 //$TBS->PlugIn( OPENTBS_DEBUG_INFO, true );
31 //$TBS->PlugIn( OPENTBS_DEBUG_XML_CURRENT );
32 //$TBS->PlugIn( OPENTBS_DEBUG_XML_SHOW );
33
34 $TBS->Show( TBS_NOTHING );
35 file_put_contents( $RootPath."/attachments/".$dbname."/invoicing/testing_result.ods", $TBS->Source );
36 echo "<a href=\"$domain/attachments/$dbname/invoicing/testing_result.ods\" target=_BLANK>$lang[download]</a>";

I have to use the file_put_contents, because of the way our downloading works, if I don't, when I have the show command, all I get is mime encoded display stuff ( ? and other odd characters ).

when I run the different debug options, I get the following:
OPENTBS_DEBUG_INFO:
* OPENTBS DEBUG MODE: if the star, (*) on the left before the word OPENTBS, is not the very first character of this page, then your merged Document will be corrupted when you use the OPENTBS_DOWNLOAD option. If there is a PHP error message, then you have to fix it. If they are blank spaces, line beaks, or other unexpected characters, then you have to check your code in order to avoid them. ------------------------------ INFORMATION ------------------------------ * Debug command: OPENTBS_DEBUG_INFO * OpenTBS version: 1.7.6 * TinyButStrong version: 3.8.0 * PHP version: 5.3.13-1~dotdeb.0 * Opened document: /var/www/nizex.com/lizzybeta/xl-forms/testing.ods * Activated features for document type: odf/ods Sheets in the Workbook: ----------------------- - id: 1, name: [Sheet1] - id: 2, name: [Sheet2] - id: 3, name: [Sheet3]

OPENTBS_DEBUG_XML_CURRENT:
* OPENTBS DEBUG MODE: if the star, (*) on the left before the word OPENTBS, is not the very first character of this page, then your merged Document will be corrupted when you use the OPENTBS_DOWNLOAD option. If there is a PHP error message, then you have to fix it. If they are blank spaces, line beaks, or other unexpected characters, then you have to check your code in order to avoid them. ------------------------------ INFORMATION ------------------------------ * Debug command: OPENTBS_DEBUG_XML_CURRENT * OpenTBS version: 1.7.6 * TinyButStrong version: 3.8.0 * PHP version: 5.3.13-1~dotdeb.0 * Opened document: /var/www/nizex.com/lizzybeta/xl-forms/testing.ods * Activated features for document type: odf/ods * Deleted files in the archive: none * Added files in the archive: none * Modified files in the archive: - styles.xml - content.xml ------------------------------ File merged with OpenTBS (XML reformated for debuging only): styles.xml ------------------------------ $ - $ ??? Page 1 ??? ( ??? ) 00/00/0000 , 00:00:00 Page 1 / 99 ------------------------------ File merged with OpenTBS (XML reformated for debuging only): content.xml ------------------------------ [onshow.x] 10 [onshow.y] 16 0 0 0

OPENTBS_DEBUG_XML_SHOW:
* OPENTBS DEBUG MODE: if the star, (*) on the left before the word OPENTBS, is not the very first character of this page, then your merged Document will be corrupted when you use the OPENTBS_DOWNLOAD option. If there is a PHP error message, then you have to fix it. If they are blank spaces, line beaks, or other unexpected characters, then you have to check your code in order to avoid them. ------------------------------ INFORMATION ------------------------------ * Debug command: OPENTBS_DEBUG_XML_SHOW * OpenTBS version: 1.7.6 * TinyButStrong version: 3.8.0 * PHP version: 5.3.13-1~dotdeb.0 * Opened document: /var/www/nizex.com/lizzybeta/xl-forms/testing.ods * Activated features for document type: odf/ods * Deleted files in the archive: none * Added files in the archive: none * Modified files in the archive: - styles.xml - content.xml ------------------------------ File merged with OpenTBS (XML reformated for debuging only): styles.xml ------------------------------ $ - $ ??? Page 1 ??? ( ??? ) 00/00/0000 , 00:00:00 Page 1 / 99 ------------------------------ File merged with OpenTBS (XML reformated for debuging only): content.xml ------------------------------ 5 10 11 16 0 0 0


Any ideas??

Thanks in Advance
Chris
By: Skrol29
Date: 2012-07-23
Time: 23:45

Re: Problem loading Spreadsheet ( ODS )

Hi Chris,

You have to replace :
$TBS->Show( TBS_NOTHING );
With :
$TBS->Show(OPENTBS_STRING);

Using TBS_NOTHING, only the last sub-file is kept in $TBS->Source. That is probably why your output file is unvalid.
By: Chris Kiraly
Date: 2012-07-24
Time: 00:01

Re: Problem loading Spreadsheet ( ODS )

Lo and Behold!!!

Thank you very much Skrol...  That fixed the problem...

By: Skrol29
Date: 2012-07-24
Time: 10:26

Re: Problem loading Spreadsheet ( ODS )

> I have to use the file_put_contents, because of the way our downloading works,
> if I don't, when I have the show command, all I get is
> mime encoded display stuff ( ? and other odd characters ).

If you use $TBS->Show(OPENTBS_FILE, $file_name); then it should do the same and it costs less memory.
With OPENTBS_FILE, only modified sub-file are saved in memory, other sub-file are taken directly from the template file.