<?php // Load library require_once '../ods.php'; // Create Ods object $ods = new ods(); //Set vertical split $table = new odsTable('V Split'); $table->setVerticalSplit(1); $ods->addTable($table); //Set Horizontal split $table = new odsTable('H Split'); $table->setHorizontalSplit(1); $ods->addTable($table); // Both split $table = new odsTable('B Split'); $table->setVerticalSplit(1); $table->setHorizontalSplit(1); $ods->addTable($table); // Download the file $ods->downloadOdsFile("TableSplit.ods");
<?php // Load library require_once '../ods.php'; // Create Ods object $ods = new ods(); // Create table named 'Cells' $table = new odsTable('Cells'); // Empty cell $row = new odsTableRow(); $row->addCell(new odsTableCellString("Empty cell")); $row->addCell(new odsTableCellEmpty()); $table->addRow($row); // String cell $row = new odsTableRow(); $row->addCell(new odsTableCellString("String cell")); $row->addCell(new odsTableCellString("String in my cell")); $table->addRow($row); // Email cell $row = new odsTableRow(); $row->addCell(new odsTableCellString("Email cell")); $row->addCell(new odsTableCellStringEmail("*****@*****.**")); $table->addRow($row); // Url cell $row = new odsTableRow(); $row->addCell(new odsTableCellString("Url cell")); $row->addCell(new odsTableCellStringUrl("http://odsphpgenerator.lapinator.net")); $table->addRow($row); // Foat cell $row = new odsTableRow(); $row->addCell(new odsTableCellString("Float cell"));
$style7 = new odsStyleTableCell(); $style7->setUnderline("font-color"); // Font size $style8 = new odsStyleTableCell(); $style8->setFontSize("18pt"); // Font Face $TimesNewRoman = new odsFontFace('Times New Roman'); $ods->addFontFaces($TimesNewRoman); $style9 = new odsStyleTableCell(); $style9->setFontFace($TimesNewRoman); // Font Face $Webdings = new odsFontFace('Webdings'); $ods->addFontFaces($Webdings); $style10 = new odsStyleTableCell(); $style10->setFontFace($Webdings); $table = new odsTable('odsStyleTableCell'); $table->addRow($row = new odsTableRow()); $row->addCell(new odsTableCellString("Red text", $style1)); $table->addRow($row = new odsTableRow()); $row->addCell(new odsTableCellString("Green background", $style2)); $table->addRow($row = new odsTableRow()); $row->addCell(new odsTableCellString("Blue border", $style3)); $table->addRow($row = new odsTableRow()); $row->addCell(new odsTableCellString("Align :")); $row->addCell(new odsTableCellString("start", $style4_1)); $row->addCell(new odsTableCellString("center", $style4_2)); $row->addCell(new odsTableCellString("end", $style4_3)); $row->addCell(new odsTableCellString("justify : 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 ... ", $style4_4)); $table->addRow($row = new odsTableRow()); $row->addCell(new odsTableCellString("Bold", $style5)); $table->addRow($row = new odsTableRow());
public function ods($start, $end) { $data = $this->gendate($start, $end); $ods = new ods(); $table = new odsTable('table 1'); $table->setHorizontalSplit(1); $table->setVerticalSplit(3); // Set coluomn width $styleColumn = new odsStyleTableColumn(); $styleColumn->setColumnWidth("4cm"); $table->addTableColumn(new odsTableColumn($styleColumn)); $table->addTableColumn($column = new odsTableColumn($styleColumn = new odsStyleTableColumn())); $styleColumn->setColumnWidth("1.5cm"); $column->setRepeated($data['total_days']); // Set Title Style $styleTitle1 = new odsStyleTableCell(); $styleTitle1->setBorder("0.01cm solid #000000"); $styleTitle1->setFontWeight('bold'); $styleTitle2 = clone $styleTitle1; $styleTitle2->setTextAlign("center"); // Months style $row = new odsTableRow(); $row->addCell(new odsTableCellString("Months:", $styleTitle1)); foreach ($data['months'] as $moi) { $cell = new odsTableCellString($moi['title'], $styleTitle2); $cell->setNumberColumnsSpanned($moi['day']); $row->addCell($cell); } $table->addRow($row); $row = new odsTableRow(); $row->addCell(new odsTableCellString("Weeks :", $styleTitle1)); foreach ($data['weeks'] as $week) { $cell = new odsTableCellString($week['title'], $styleTitle2); $cell->setNumberColumnsSpanned($week['day']); $row->addCell($cell); } $table->addRow($row); $row = new odsTableRow(); $row->addCell(new odsTableCellString("Days:", $styleTitle1)); foreach ($data['days'] as $day) { $cell = new odsTableCellString($day['title'], $styleTitle2); $cell->setNumberColumnsSpanned($day['day']); $row->addCell($cell); } $table->addRow($row); foreach ($data['projects'] as $projet) { $row = new odsTableRow(); $row->addCell(new odsTableCellString($projet['title'], $styleTitle1)); if ($projet["shift"]) { $cell = new odsTableCellEmpty(); $cell->setNumberColumnsRepeated($projet["shift"]); $row->addCell($cell); } $styleX = clone $styleTitle2; $styleX->setBackgroundColor($projet[color]); $cell = new odsTableCellString($projet['title'], $styleX); $cell->setNumberColumnsSpanned($projet['days']); $row->addCell($cell); $table->addRow($row); } $ods->addTable($table); $ods->downloadOdsFile("tab.ods"); exit; }
<?php // This example is writen in UTF-8 // Load library require_once '../ods.php'; // Create Ods object $ods = new ods(); // Create table named 'table 1' $table1 = new odsTable('table 1'); $row = new odsTableRow(); $row->addCell(new odsTableCellString("Hello")); $row->addCell(new odsTableCellString("World")); $table1->addRow($row); $ods->addTable($table1); // Create table named 'table 2' $table2 = new odsTable('table 2'); $row = new odsTableRow(); $row->addCell(new odsTableCellString("Rand1")); $row->addCell(new odsTableCellString("=")); $row->addCell(new odsTableCellString(rand())); $table2->addRow($row); $row = new odsTableRow(); $row->addCell(new odsTableCellString("Rand2")); $row->addCell(new odsTableCellString("=")); $row->addCell(new odsTableCellString(rand())); $table2->addRow($row); $ods->addTable($table2); //Select 'table 2' $ods->setDefaultTable($table2); // Download the file $ods->downloadOdsFile("multiTable.ods");
<?php // Load library require_once '../ods.php'; // Create Ods object $ods = new ods(); $table = new odsTable('Column Width'); // create column width 1cm $styleColumn = new odsStyleTableColumn(); $styleColumn->setColumnWidth("1cm"); $column1 = new odsTableColumn($styleColumn); // create column width 7cm $styleColumn = new odsStyleTableColumn(); $styleColumn->setColumnWidth("7cm"); $column2 = new odsTableColumn($styleColumn); // add 2 1cm column $table->addTableColumn($column1); $table->addTableColumn($column1); // add 1 7cm column $table->addTableColumn($column2); // Create data $table->addRow($row = new odsTableRow()); $row->addCell(new odsTableCellString("1cm")); $row->addCell(new odsTableCellString("1cm")); $row->addCell(new odsTableCellString("7cm ...")); // Add table to ods $ods->addTable($table); // Download the file $ods->downloadOdsFile("ColumnWidth.ods");