source: extensions/GrumPluginClasses/classes/External/odsPhpGenerator/examples/Formula.php @ 17735

Last change on this file since 17735 was 17735, checked in by grum, 12 years ago

version 3.5.4 - fix minor bug & add new functions to framework

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1<?php
2// All file is writen in UTF-8
3
4// Load library
5require_once('../ods.php');
6
7// Create Ods object
8$ods  = new ods();
9
10// Create table named 'table 1'
11$table = new odsTable('table 1');
12
13// Create the first row
14$row   = new odsTableRow();
15
16// Create 10 number cell
17for($i=0; $i<10; $i++) {
18        $row  = new odsTableRow();
19        $row->addCell( new odsTableCellEmpty());
20        $row->addCell( new odsTableCellFloat(rand(0,50)));
21        $table->addRow($row);
22}
23
24// Add Formula cell
25// Forumla is writen in english language, it's internal format for formula
26$row  = new odsTableRow();
27
28$row->addCell( new odsTableCellString("Sum :") );
29
30$cell = new odsTableCellFloat(0);
31$cell->setFormula("SUM([.B1:.B10])");
32$row->addCell( $cell );
33
34$table->addRow($row);
35
36// Empty row
37$row  = new odsTableRow();
38$table->addRow($row);
39
40// 2nd example contatenate string
41$row  = new odsTableRow();
42
43$row->addCell( new odsTableCellString("Laurent") );
44$row->addCell( new odsTableCellString("VUIBERT") );
45
46$cell = new odsTableCellString("");
47$row->addCell( $cell );
48$cell->setFormula('CONCATENATE([.A13];" ";[.B13];" : ";[.B11])');
49
50$table->addRow($row);
51
52
53// Attach talble to ods
54$ods->addTable($table);
55
56// Download the file
57$ods->downloadOdsFile("HelloWorld.ods");
58
59
60?>
Note: See TracBrowser for help on using the repository browser.