30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
38 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/IWriter.php';
41 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/HTML.php';
44 require_once PHPEXCEL_ROOT .
'PHPExcel/Cell.php';
47 require_once PHPEXCEL_ROOT .
'PHPExcel/RichText.php';
50 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/Drawing.php';
53 require_once PHPEXCEL_ROOT .
'PHPExcel/HashTable.php';
56 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/PDF.php';
82 $this->_tempDir = sys_get_temp_dir();
91 public function save($pFilename = null) {
93 $this->_phpExcel->garbageCollect();
99 $fileHandle = fopen($pFilename,
'w');
100 if ($fileHandle ===
false) {
101 throw new Exception(
"Could not open file $pFilename for writing.");
105 $this->_isPdf =
true;
122 $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() ==
'landscape' ?
'L' :
'P';
124 $orientation = $this->_phpExcel->getSheet($this->
getSheetIndex())->getPageSetup()->getOrientation() ==
'landscape' ?
'L' :
'P';
128 $pdf =
new TCPDF($orientation,
'pt', $paperSize);
129 $pdf->setPrintHeader(
false);
130 $pdf->setPrintFooter(
false);
132 $pdf->SetFont(
'freesans');
133 $pdf->writeHTML($html);
136 $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
137 $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
138 $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
139 $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
140 $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
143 fwrite($fileHandle, $pdf->output($pFilename,
'S'));
168 if (is_dir($pValue)) {
169 $this->_tempDir = $pValue;
171 throw new Exception(
"Directory does not exist: $pValue");