ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
26utf8.php
Go to the documentation of this file.
1 <?php
29 error_reporting(E_ALL);
30 ini_set('display_errors', TRUE);
31 ini_set('display_startup_errors', TRUE);
32 
33 define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
34 
35 date_default_timezone_set('Europe/London');
36 
38 require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
39 
40 
41 // Change these values to select the PDF Rendering library that you wish to use
42 // and its directory location on your server
43 //$rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
44 //$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
46 //$rendererLibrary = 'tcPDF5.9';
47 //$rendererLibrary = 'mPDF5.4';
48 $rendererLibrary = 'domPDF0.6.0beta3';
49 $rendererLibraryPath = '/php/libraries/PDF/' . $rendererLibrary;
50 
51 
52 // Read from Excel2007 (.xlsx) template
53 echo date('H:i:s') , " Load Excel2007 template file" , EOL;
55 $objPHPExcel = $objReader->load("templates/26template.xlsx");
56 
59 // Export to Excel2007 (.xlsx)
60 echo date('H:i:s') , " Write to Excel5 format" , EOL;
62 $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
63 echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
64 
65 // Export to Excel5 (.xls)
66 echo date('H:i:s') , " Write to Excel5 format" , EOL;
68 $objWriter->save(str_replace('.php', '.xls', __FILE__));
69 echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
70 
71 // Export to HTML (.html)
72 echo date('H:i:s') , " Write to HTML format" , EOL;
74 $objWriter->save(str_replace('.php', '.htm', __FILE__));
75 echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
76 
77 // Export to PDF (.pdf)
78 echo date('H:i:s') , " Write to PDF format" , EOL;
79 try {
83  )) {
84  echo (
85  'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
86  EOL .
87  'at the top of this script as appropriate for your directory structure' .
88  EOL
89  );
90  } else {
92  $objWriter->save(str_replace('.php', '.pdf', __FILE__));
93  echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
94  }
95 } catch (Exception $e) {
96  echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL;
97 }
98 
99 // Remove first two rows with field headers before exporting to CSV
100 echo date('H:i:s') , " Removing first two heading rows for CSV export" , EOL;
101 $objWorksheet = $objPHPExcel->getActiveSheet();
102 $objWorksheet->removeRow(1, 2);
103 
104 // Export to CSV (.csv)
105 echo date('H:i:s') , " Write to CSV format" , EOL;
107 $objWriter->save(str_replace('.php', '.csv', __FILE__));
108 echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
109 
110 // Export to CSV with BOM (.csv)
111 echo date('H:i:s') , " Write to CSV format (with BOM)" , EOL;
112 $objWriter->setUseBOM(true);
113 $objWriter->save(str_replace('.php', '-bom.csv', __FILE__));
114 echo date('H:i:s') , " File written to " , str_replace('.php', '-bom.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
115 
116 
117 // Echo memory peak usage
118 echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
119 
120 // Echo done
121 echo date('H:i:s') , " Done writing files" , EOL;
122 echo 'Files have been created in ' , getcwd() , EOL;
const PDF_RENDERER_DOMPDF
Definition: Settings.php:50
$objReader
Definition: 26utf8.php:54
static setPdfRenderer($libraryName, $libraryBaseDir)
Set details of the external library that PHPExcel should use for rendering PDF files.
Definition: Settings.php:287
$rendererLibraryPath
Definition: 26utf8.php:49
static createReader($readerType='')
Create PHPExcel_Reader_IReader.
Definition: IOFactory.php:161
$objWorksheet
Definition: 26utf8.php:101
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$rendererLibrary
Definition: 26utf8.php:48
$rendererName
Include PHPExcel.
Definition: 26utf8.php:45
$objWriter
Definition: 26utf8.php:61
$objPHPExcel
Definition: 26utf8.php:55
const EOL
Definition: 26utf8.php:33