Home
PHP
Application
Php Manual
Pictures
GuestBook
 
 
  Introduction Dlog Aprint SpTpl 
  Yap Xml2Array

 

 

 
 
 
Ex. index Quick Start Basic ex.
1st report Database Columns
Pdf output Pdf report Tag function
   

Columns example.

Here I'll show you an simple example how to configure, how to use the columnset.

The PHP script

<?php
/*
* Column test
* $Header: d:/cvs/classistd/sptpl/test/test18.php,v 2.2 2004/02/10 22:08:46 Administrator Exp $
*/
function foo()
{
return(
"text from foo");
}

function
foop($text)
{
return(
"my parameter:".$text);
}


require_once(
'../sptpl.php');
require_once(
'../sptpl.inc');
require_once(
'../sptpl_db.php');

set_time_limit(0);
$t=new sptpl();
$t->LoadTemplate('test18.xml');
$t->SetVar("name","George");
$t->SetVar("MyName","Sam");
$bar['foo']='Index foo';
$t->SetVar("bar",$bar);
// $t->_DumpInternals();
// die;
$t->run("test18.txt");
?>

Second step, write the configuration file test18.xml

<?xml version='1.0' ?>

<template>
<constant name='const1' value = '1'/>
<constant name='const2' value = '2'/>

<field name='fld1'>
  <sourcefield>fld1</sourcefield>
  <stringformat>none</stringformat>
  <dateformat>none</dateformat>
  <value>13</value>
</field>


<report>
  <beginreport>
   Hi

   My First Test
  </beginreport>
  <OpenPage>
Column test 1
  </OpenPage>
  <row id='pippo'>
Some text without set the column
  </row>

  <!-- set a new columnset -->
  <columnset id='test1'>
   <column  leftpos='5' Width='20' align='center' />
   <column  leftpos='26' Width='20' align='right' />
   <column  leftpos='47' Width='20' align='left' />
  </columnset>

  <!-- Now write the following text using the columnset test1,
  at column 1 -->

  <row columnset='test1' column='1'>Text on the first column
  </row>

  <!-- Some text at column 2. Notice I already activated the columnset
  test1, so I don't need add the columnset attribute -->

  <row column='2'>Text on the second column
  </row>

  <row column='3'>Text on the third column
  </row>

  <!-- Are the texts place in the right position? Notice
  the align became from the column definition. If I add the
  align attribute to the following row tag, it override the column
  definition -->

  <row column='1'>Align: center
  </row>

  <row column='2'>Align: right
  </row>

  <row column='3'>Align: left
  </row>

  <newpage/>

  <!-- No column set, the module writes the text into column 0
  that is the whole page -->

  <row>Another page</row>

  <row vpos='absolute' rowpos='5'/>
  <row>Another text</row>

  <closepage>
Page end - {$PageNumber}
  </closepage>
  <closereport>
   End!That's all folk!
  </closereport>


</report>


</template>

And this is the output from the previous code

  Column test 1

     Hi

     My First Test
  Some text without set the column
      Text on the first     Text on the second Text on the third
            column                      column  column
        Align: center             Align: right Align: left
























































  Page end - 1
  Column test 1

  Another page

  Another text
     End!That's all folk!



























































  Page end - 2

 

Copyright © 2003-2008 Darvin Andrioli, last change 31/07/2006