Beste PHP'ers,
Ik ben bezig uit te zoeken wat de beste manier is om data (afkomstig uit een c++ applicatie) om te zetten naar een OpenOffice writer(.odt) & PDF bestand. De data bevat onder andere grafieken en tabellen. Ik dacht dit te kunnen realiseren d.m.v. een php script, en ben dus gaan zoeken. Uiteindelijk ben ik bij de library TinyButStrong beland, aangezien die een plugin heeft; openTBS, om een OO writer bestand te vullen met data.
Het probleem is dat ik hier nog nooit mee gewerkt heb, en weinig tot geen tutorials kan vinden.
Ik moet een beetje hetzelfde als dit krijgen. De library leren kennen daar gaat natuurlijk wat tijd en moeite in zitten, maar voor nu lukt het me niet eens een template te openen. iemand een idee wat er hier fout gaat?
<?php
// load the TinyButStrong libraries
if (version_compare(PHP_VERSION,'5')<0) {
include_once('tbs_class.php'); // TinyButStrong template engine for PHP 4
} else {
include_once('tbs_class.php'); // TinyButStrong template engine
}
// load the OpenTBS plugin
if (file_exists('tbs_plugin_opentbs.php')) {
include_once('tbs_plugin_opentbs.php');
} else {
include_once('../tbs_plugin_opentbs.php');
}
$TBS = new clsTinyButStrong; // new instance of TBS
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load OpenTBS plugin
$data = array();
$data[] = array('firstname'=>'Sandra' , 'name'=>'Hill' , 'number'=>'1523d', 'score'=>200, 'email_1'=>'[email protected]', 'email_2'=>'[email protected]', 'email_3'=>'[email protected]');
$data[] = array('firstname'=>'Roger' , 'name'=>'Smith' , 'number'=>'1234f', 'score'=>800, 'email_1'=>'[email protected]', 'email_2'=>'[email protected]', 'email_3'=>'[email protected]' );
$data[] = array('firstname'=>'William', 'name'=>'Mac Dowell', 'number'=>'5491y', 'score'=>130, 'email_1'=>'[email protected]', 'email_2'=>'[email protected]', 'email_3'=>'[email protected]' );
$TBS->LoadTemplate("test2.odt");
//hiermee zou hij de tabel moeten vullen neem ik aan?
$TBS->MergeBlock('a,b', $data);
// Define the name of the output file
$file_name = str_replace('.','_'.date('Y-m-d').'.','test.odt');
// download
$TBS->Show(OPENTBS_DOWNLOAD, $file_name);
// save as file
$TBS->Show(OPENTBS_FILE+TBS_EXIT, $file_name);
?>
Ik gebruik overigens gewoon de template van de demo.
Alvast bedankt,
Max
1.915 views