@@ -132,7 +132,7 @@ |
||
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @param array $input |
135 | - * @param $delimiter |
|
135 | + * @param string $delimiter |
|
136 | 136 | * @return null|string |
137 | 137 | * @since 1.0.4 |
138 | 138 | */ |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $output = null; |
142 | 142 | foreach ($input as $row) { |
143 | - $output.= self::generateRow($row, $delimiter, '"'); |
|
143 | + $output .= self::generateRow($row, $delimiter, '"'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $output; |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected static function generateRow(array $row, $delimiter, $enclose) |
159 | 159 | { |
160 | - array_walk($row, function (&$item) use ($enclose) { |
|
160 | + array_walk($row, function(&$item) use ($enclose) { |
|
161 | 161 | if (!is_scalar($item)) { |
162 | 162 | $item = "array"; |
163 | 163 | } |
164 | 164 | $item = $enclose.Html::encode($item).$enclose; |
165 | 165 | }); |
166 | 166 | |
167 | - return implode($delimiter, $row) . PHP_EOL; |
|
167 | + return implode($delimiter, $row).PHP_EOL; |
|
168 | 168 | } |
169 | 169 | } |
@@ -109,6 +109,9 @@ discard block |
||
109 | 109 | return $string; |
110 | 110 | } |
111 | 111 | |
112 | + /** |
|
113 | + * @param string $filename |
|
114 | + */ |
|
112 | 115 | public function writeToFile($filename) |
113 | 116 | { |
114 | 117 | foreach ($this->sheets as $sheet_name => $sheet) { |
@@ -237,6 +240,9 @@ discard block |
||
237 | 240 | $sheet->file_writer->write('<sheetData>'); |
238 | 241 | } |
239 | 242 | |
243 | + /** |
|
244 | + * @param null|string $cell_style_string |
|
245 | + */ |
|
240 | 246 | private function addCellStyle($number_format, $cell_style_string) |
241 | 247 | { |
242 | 248 | $number_format_idx = self::add_to_list_get_index($this->number_formats, $number_format); |
@@ -261,6 +267,9 @@ discard block |
||
261 | 267 | return $column_types; |
262 | 268 | } |
263 | 269 | |
270 | + /** |
|
271 | + * @param string $sheet_name |
|
272 | + */ |
|
264 | 273 | public function writeSheetHeader($sheet_name, array $header_types, $col_options = null) |
265 | 274 | { |
266 | 275 | if (empty($sheet_name) || empty($header_types) || !empty($this->sheets[$sheet_name])) { |
@@ -296,6 +305,9 @@ discard block |
||
296 | 305 | $this->current_sheet = $sheet_name; |
297 | 306 | } |
298 | 307 | |
308 | + /** |
|
309 | + * @param string $sheet_name |
|
310 | + */ |
|
299 | 311 | public function writeSheetRow($sheet_name, array $row, $row_options = null) |
300 | 312 | { |
301 | 313 | if (empty($sheet_name)) { |
@@ -409,6 +421,10 @@ discard block |
||
409 | 421 | $this->finalizeSheet($sheet_name); |
410 | 422 | } |
411 | 423 | |
424 | + /** |
|
425 | + * @param integer $row_number |
|
426 | + * @param integer $column_number |
|
427 | + */ |
|
412 | 428 | protected function writeCell( |
413 | 429 | XLSXWriter_BuffererWriter &$file, |
414 | 430 | $row_number, |
@@ -863,6 +879,10 @@ discard block |
||
863 | 879 | } |
864 | 880 | |
865 | 881 | //------------------------------------------------------------------ |
882 | + |
|
883 | + /** |
|
884 | + * @param string $num_format |
|
885 | + */ |
|
866 | 886 | private static function determineNumberFormatType($num_format) |
867 | 887 | { |
868 | 888 | $num_format = preg_replace("/\[(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow)\]/i", "", $num_format); |
@@ -1053,6 +1073,9 @@ discard block |
||
1053 | 1073 | protected $buffer = ''; |
1054 | 1074 | protected $check_utf8 = false; |
1055 | 1075 | |
1076 | + /** |
|
1077 | + * @param string $filename |
|
1078 | + */ |
|
1056 | 1079 | public function __construct($filename, $fd_fopen_flags = 'w', $check_utf8 = false) |
1057 | 1080 | { |
1058 | 1081 | $this->check_utf8 = $check_utf8; |
@@ -1114,6 +1137,9 @@ discard block |
||
1114 | 1137 | return -1; |
1115 | 1138 | } |
1116 | 1139 | |
1140 | + /** |
|
1141 | + * @param string $string |
|
1142 | + */ |
|
1117 | 1143 | protected static function isValidUTF8($string) |
1118 | 1144 | { |
1119 | 1145 | if (function_exists('mb_check_encoding')) { |
@@ -112,24 +112,24 @@ discard block |
||
112 | 112 | public function writeToFile($filename) |
113 | 113 | { |
114 | 114 | foreach ($this->sheets as $sheet_name => $sheet) { |
115 | - self::finalizeSheet($sheet_name);//making sure all footers have been written |
|
115 | + self::finalizeSheet($sheet_name); //making sure all footers have been written |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | if (file_exists($filename)) { |
119 | 119 | if (is_writable($filename)) { |
120 | 120 | @unlink($filename); //if the zip already exists, remove it |
121 | 121 | } else { |
122 | - self::log("Error in " . __CLASS__ . "::" . __FUNCTION__ . ", file is not writeable."); |
|
122 | + self::log("Error in ".__CLASS__."::".__FUNCTION__.", file is not writeable."); |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | $zip = new ZipArchive(); |
127 | 127 | if (empty($this->sheets)) { |
128 | - self::log("Error in " . __CLASS__ . "::" . __FUNCTION__ . ", no worksheets defined."); |
|
128 | + self::log("Error in ".__CLASS__."::".__FUNCTION__.", no worksheets defined."); |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | if (!$zip->open($filename, ZipArchive::CREATE)) { |
132 | - self::log("Error in " . __CLASS__ . "::" . __FUNCTION__ . ", unable to create zip."); |
|
132 | + self::log("Error in ".__CLASS__."::".__FUNCTION__.", unable to create zip."); |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | |
143 | 143 | $zip->addEmptyDir("xl/worksheets/"); |
144 | 144 | foreach ($this->sheets as $sheet) { |
145 | - $zip->addFile($sheet->filename, "xl/worksheets/" . $sheet->xmlname); |
|
145 | + $zip->addFile($sheet->filename, "xl/worksheets/".$sheet->xmlname); |
|
146 | 146 | } |
147 | 147 | $zip->addFromString("xl/workbook.xml", self::buildWorkbookXML()); |
148 | 148 | $zip->addFile($this->writeStylesXML(), |
149 | - "xl/styles.xml"); //$zip->addFromString("xl/styles.xml" , self::buildStylesXML() ); |
|
149 | + "xl/styles.xml"); //$zip->addFromString("xl/styles.xml" , self::buildStylesXML() ); |
|
150 | 150 | $zip->addFromString("[Content_Types].xml", self::buildContentTypesXML()); |
151 | 151 | |
152 | 152 | $zip->addEmptyDir("xl/_rels/"); |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | $sheet_filename = $this->tempFilename(); |
170 | - $sheet_xmlname = 'sheet' . (count($this->sheets) + 1) . ".xml"; |
|
171 | - $this->sheets[$sheet_name] = (object)array( |
|
170 | + $sheet_xmlname = 'sheet'.(count($this->sheets) + 1).".xml"; |
|
171 | + $this->sheets[$sheet_name] = (object) array( |
|
172 | 172 | 'filename' => $sheet_filename, |
173 | 173 | 'sheetname' => $sheet_name, |
174 | 174 | 'xmlname' => $sheet_xmlname, |
@@ -184,41 +184,41 @@ discard block |
||
184 | 184 | 'finalized' => false, |
185 | 185 | ); |
186 | 186 | $sheet = &$this->sheets[$sheet_name]; |
187 | - $tabselected = count($this->sheets) == 1 ? 'true' : 'false';//only first sheet is selected |
|
188 | - $max_cell = XLSXWriter::xlsCell(self::EXCEL_2007_MAX_ROW, self::EXCEL_2007_MAX_COL);//XFE1048577 |
|
189 | - $sheet->file_writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"); |
|
187 | + $tabselected = count($this->sheets) == 1 ? 'true' : 'false'; //only first sheet is selected |
|
188 | + $max_cell = XLSXWriter::xlsCell(self::EXCEL_2007_MAX_ROW, self::EXCEL_2007_MAX_COL); //XFE1048577 |
|
189 | + $sheet->file_writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"); |
|
190 | 190 | $sheet->file_writer->write('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'); |
191 | 191 | $sheet->file_writer->write('<sheetPr filterMode="false">'); |
192 | 192 | $sheet->file_writer->write('<pageSetUpPr fitToPage="false"/>'); |
193 | 193 | $sheet->file_writer->write('</sheetPr>'); |
194 | 194 | $sheet->max_cell_tag_start = $sheet->file_writer->ftell(); |
195 | - $sheet->file_writer->write('<dimension ref="A1:' . $max_cell . '"/>'); |
|
195 | + $sheet->file_writer->write('<dimension ref="A1:'.$max_cell.'"/>'); |
|
196 | 196 | $sheet->max_cell_tag_end = $sheet->file_writer->ftell(); |
197 | 197 | $sheet->file_writer->write('<sheetViews>'); |
198 | - $sheet->file_writer->write('<sheetView colorId="64" defaultGridColor="true" rightToLeft="false" showFormulas="false" showGridLines="true" showOutlineSymbols="true" showRowColHeaders="true" showZeros="true" tabSelected="' . $tabselected . '" topLeftCell="A1" view="normal" windowProtection="false" workbookViewId="0" zoomScale="100" zoomScaleNormal="100" zoomScalePageLayoutView="100">'); |
|
198 | + $sheet->file_writer->write('<sheetView colorId="64" defaultGridColor="true" rightToLeft="false" showFormulas="false" showGridLines="true" showOutlineSymbols="true" showRowColHeaders="true" showZeros="true" tabSelected="'.$tabselected.'" topLeftCell="A1" view="normal" windowProtection="false" workbookViewId="0" zoomScale="100" zoomScaleNormal="100" zoomScalePageLayoutView="100">'); |
|
199 | 199 | if ($sheet->freeze_rows && $sheet->freeze_columns) { |
200 | - $sheet->file_writer->write('<pane ySplit="' . $sheet->freeze_rows . '" xSplit="' . $sheet->freeze_columns . '" topLeftCell="' . self::xlsCell($sheet->freeze_rows, |
|
201 | - $sheet->freeze_columns) . '" activePane="bottomRight" state="frozen"/>'); |
|
202 | - $sheet->file_writer->write('<selection activeCell="' . self::xlsCell($sheet->freeze_rows, |
|
203 | - 0) . '" activeCellId="0" pane="topRight" sqref="' . self::xlsCell($sheet->freeze_rows, 0) . '"/>'); |
|
204 | - $sheet->file_writer->write('<selection activeCell="' . self::xlsCell(0, |
|
205 | - $sheet->freeze_columns) . '" activeCellId="0" pane="bottomLeft" sqref="' . self::xlsCell(0, |
|
206 | - $sheet->freeze_columns) . '"/>'); |
|
207 | - $sheet->file_writer->write('<selection activeCell="' . self::xlsCell($sheet->freeze_rows, |
|
208 | - $sheet->freeze_columns) . '" activeCellId="0" pane="bottomRight" sqref="' . self::xlsCell($sheet->freeze_rows, |
|
209 | - $sheet->freeze_columns) . '"/>'); |
|
200 | + $sheet->file_writer->write('<pane ySplit="'.$sheet->freeze_rows.'" xSplit="'.$sheet->freeze_columns.'" topLeftCell="'.self::xlsCell($sheet->freeze_rows, |
|
201 | + $sheet->freeze_columns).'" activePane="bottomRight" state="frozen"/>'); |
|
202 | + $sheet->file_writer->write('<selection activeCell="'.self::xlsCell($sheet->freeze_rows, |
|
203 | + 0).'" activeCellId="0" pane="topRight" sqref="'.self::xlsCell($sheet->freeze_rows, 0).'"/>'); |
|
204 | + $sheet->file_writer->write('<selection activeCell="'.self::xlsCell(0, |
|
205 | + $sheet->freeze_columns).'" activeCellId="0" pane="bottomLeft" sqref="'.self::xlsCell(0, |
|
206 | + $sheet->freeze_columns).'"/>'); |
|
207 | + $sheet->file_writer->write('<selection activeCell="'.self::xlsCell($sheet->freeze_rows, |
|
208 | + $sheet->freeze_columns).'" activeCellId="0" pane="bottomRight" sqref="'.self::xlsCell($sheet->freeze_rows, |
|
209 | + $sheet->freeze_columns).'"/>'); |
|
210 | 210 | } elseif ($sheet->freeze_rows) { |
211 | - $sheet->file_writer->write('<pane ySplit="' . $sheet->freeze_rows . '" topLeftCell="' . self::xlsCell($sheet->freeze_rows, |
|
212 | - 0) . '" activePane="bottomLeft" state="frozen"/>'); |
|
213 | - $sheet->file_writer->write('<selection activeCell="' . self::xlsCell($sheet->freeze_rows, |
|
214 | - 0) . '" activeCellId="0" pane="bottomLeft" sqref="' . self::xlsCell($sheet->freeze_rows, |
|
215 | - 0) . '"/>'); |
|
211 | + $sheet->file_writer->write('<pane ySplit="'.$sheet->freeze_rows.'" topLeftCell="'.self::xlsCell($sheet->freeze_rows, |
|
212 | + 0).'" activePane="bottomLeft" state="frozen"/>'); |
|
213 | + $sheet->file_writer->write('<selection activeCell="'.self::xlsCell($sheet->freeze_rows, |
|
214 | + 0).'" activeCellId="0" pane="bottomLeft" sqref="'.self::xlsCell($sheet->freeze_rows, |
|
215 | + 0).'"/>'); |
|
216 | 216 | } elseif ($sheet->freeze_columns) { |
217 | - $sheet->file_writer->write('<pane xSplit="' . $sheet->freeze_columns . '" topLeftCell="' . self::xlsCell(0, |
|
218 | - $sheet->freeze_columns) . '" activePane="topRight" state="frozen"/>'); |
|
219 | - $sheet->file_writer->write('<selection activeCell="' . self::xlsCell(0, |
|
220 | - $sheet->freeze_columns) . '" activeCellId="0" pane="topRight" sqref="' . self::xlsCell(0, |
|
221 | - $sheet->freeze_columns) . '"/>'); |
|
217 | + $sheet->file_writer->write('<pane xSplit="'.$sheet->freeze_columns.'" topLeftCell="'.self::xlsCell(0, |
|
218 | + $sheet->freeze_columns).'" activePane="topRight" state="frozen"/>'); |
|
219 | + $sheet->file_writer->write('<selection activeCell="'.self::xlsCell(0, |
|
220 | + $sheet->freeze_columns).'" activeCellId="0" pane="topRight" sqref="'.self::xlsCell(0, |
|
221 | + $sheet->freeze_columns).'"/>'); |
|
222 | 222 | } else { // not frozen |
223 | 223 | $sheet->file_writer->write('<selection activeCell="A1" activeCellId="0" pane="topLeft" sqref="A1"/>'); |
224 | 224 | } |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | $i = 0; |
229 | 229 | if (!empty($col_widths)) { |
230 | 230 | foreach ($col_widths as $column_width) { |
231 | - $sheet->file_writer->write('<col collapsed="false" hidden="false" max="' . ($i + 1) . '" min="' . ($i + 1) . '" style="0" customWidth="true" width="' . floatval($column_width) . '"/>'); |
|
231 | + $sheet->file_writer->write('<col collapsed="false" hidden="false" max="'.($i + 1).'" min="'.($i + 1).'" style="0" customWidth="true" width="'.floatval($column_width).'"/>'); |
|
232 | 232 | $i++; |
233 | 233 | } |
234 | 234 | } |
235 | - $sheet->file_writer->write('<col collapsed="false" hidden="false" max="1024" min="' . ($i + 1) . '" style="0" customWidth="false" width="11.5"/>'); |
|
235 | + $sheet->file_writer->write('<col collapsed="false" hidden="false" max="1024" min="'.($i + 1).'" style="0" customWidth="false" width="11.5"/>'); |
|
236 | 236 | $sheet->file_writer->write('</cols>'); |
237 | 237 | $sheet->file_writer->write('<sheetData>'); |
238 | 238 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | private function addCellStyle($number_format, $cell_style_string) |
241 | 241 | { |
242 | 242 | $number_format_idx = self::add_to_list_get_index($this->number_formats, $number_format); |
243 | - $lookup_string = $number_format_idx . ";" . $cell_style_string; |
|
243 | + $lookup_string = $number_format_idx.";".$cell_style_string; |
|
244 | 244 | $cell_style_idx = self::add_to_list_get_index($this->cell_styles, $lookup_string); |
245 | 245 | return $cell_style_idx; |
246 | 246 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $number_format_type = self::determineNumberFormatType($number_format); |
254 | 254 | $cell_style_idx = $this->addCellStyle($number_format, $style_string = null); |
255 | 255 | $column_types[] = array( |
256 | - 'number_format' => $number_format,//contains excel format like 'YYYY-MM-DD HH:MM:SS' |
|
256 | + 'number_format' => $number_format, //contains excel format like 'YYYY-MM-DD HH:MM:SS' |
|
257 | 257 | 'number_format_type' => $number_format_type, //contains friendly format like 'datetime' |
258 | 258 | 'default_cell_style' => $cell_style_idx, |
259 | 259 | ); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | $style = &$col_options; |
276 | 276 | |
277 | - $col_widths = isset($col_options['widths']) ? (array)$col_options['widths'] : array(); |
|
277 | + $col_widths = isset($col_options['widths']) ? (array) $col_options['widths'] : array(); |
|
278 | 278 | $auto_filter = isset($col_options['auto_filter']) ? intval($col_options['auto_filter']) : false; |
279 | 279 | $freeze_rows = isset($col_options['freeze_rows']) ? intval($col_options['freeze_rows']) : false; |
280 | 280 | $freeze_columns = isset($col_options['freeze_columns']) ? intval($col_options['freeze_columns']) : false; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | if (!$suppress_row) { |
285 | 285 | $header_row = array_keys($header_types); |
286 | 286 | |
287 | - $sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . (1) . '">'); |
|
287 | + $sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'.(1).'">'); |
|
288 | 288 | foreach ($header_row as $c => $v) { |
289 | 289 | $cell_style_idx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle('GENERAL', |
290 | 290 | json_encode(isset($style[0]) ? $style[$c] : $style)); |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | $sheet = &$this->sheets[$sheet_name]; |
307 | 307 | if (count($sheet->columns) < count($row)) { |
308 | 308 | $default_column_types = $this->initializeColumnTypes(array_fill($from = 0, $until = count($row), |
309 | - 'GENERAL'));//will map to n_auto |
|
310 | - $sheet->columns = array_merge((array)$sheet->columns, $default_column_types); |
|
309 | + 'GENERAL')); //will map to n_auto |
|
310 | + $sheet->columns = array_merge((array) $sheet->columns, $default_column_types); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | if (!empty($row_options)) { |
314 | 314 | $ht = isset($row_options['height']) ? floatval($row_options['height']) : 12.1; |
315 | 315 | $customHt = isset($row_options['height']) ? true : false; |
316 | - $hidden = isset($row_options['hidden']) ? (bool)($row_options['hidden']) : false; |
|
317 | - $collapsed = isset($row_options['collapsed']) ? (bool)($row_options['collapsed']) : false; |
|
318 | - $sheet->file_writer->write('<row collapsed="' . ($collapsed) . '" customFormat="false" customHeight="' . ($customHt) . '" hidden="' . ($hidden) . '" ht="' . ($ht) . '" outlineLevel="0" r="' . ($sheet->row_count + 1) . '">'); |
|
316 | + $hidden = isset($row_options['hidden']) ? (bool) ($row_options['hidden']) : false; |
|
317 | + $collapsed = isset($row_options['collapsed']) ? (bool) ($row_options['collapsed']) : false; |
|
318 | + $sheet->file_writer->write('<row collapsed="'.($collapsed).'" customFormat="false" customHeight="'.($customHt).'" hidden="'.($hidden).'" ht="'.($ht).'" outlineLevel="0" r="'.($sheet->row_count + 1).'">'); |
|
319 | 319 | } else { |
320 | - $sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . ($sheet->row_count + 1) . '">'); |
|
320 | + $sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'.($sheet->row_count + 1).'">'); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | $style = &$row_options; |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | if (!empty($sheet->merge_cells)) { |
355 | 355 | $sheet->file_writer->write('<mergeCells>'); |
356 | 356 | foreach ($sheet->merge_cells as $range) { |
357 | - $sheet->file_writer->write('<mergeCell ref="' . $range . '"/>'); |
|
357 | + $sheet->file_writer->write('<mergeCell ref="'.$range.'"/>'); |
|
358 | 358 | } |
359 | 359 | $sheet->file_writer->write('</mergeCells>'); |
360 | 360 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $max_cell = self::xlsCell($sheet->row_count - 1, count($sheet->columns) - 1); |
363 | 363 | |
364 | 364 | if ($sheet->auto_filter) { |
365 | - $sheet->file_writer->write('<autoFilter ref="A1:' . $max_cell . '"/>'); |
|
365 | + $sheet->file_writer->write('<autoFilter ref="A1:'.$max_cell.'"/>'); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | $sheet->file_writer->write('<printOptions headings="false" gridLines="false" gridLinesSet="true" horizontalCentered="false" verticalCentered="false"/>'); |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | $sheet->file_writer->write('</headerFooter>'); |
375 | 375 | $sheet->file_writer->write('</worksheet>'); |
376 | 376 | |
377 | - $max_cell_tag = '<dimension ref="A1:' . $max_cell . '"/>'; |
|
377 | + $max_cell_tag = '<dimension ref="A1:'.$max_cell.'"/>'; |
|
378 | 378 | $padding_length = $sheet->max_cell_tag_end - $sheet->max_cell_tag_start - strlen($max_cell_tag); |
379 | 379 | $sheet->file_writer->fseek($sheet->max_cell_tag_start); |
380 | - $sheet->file_writer->write($max_cell_tag . str_repeat(" ", $padding_length)); |
|
380 | + $sheet->file_writer->write($max_cell_tag.str_repeat(" ", $padding_length)); |
|
381 | 381 | $sheet->file_writer->close(); |
382 | 382 | $sheet->finalized = true; |
383 | 383 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | $startCell = self::xlsCell($start_cell_row, $start_cell_column); |
395 | 395 | $endCell = self::xlsCell($end_cell_row, $end_cell_column); |
396 | - $sheet->merge_cells[] = $startCell . ":" . $endCell; |
|
396 | + $sheet->merge_cells[] = $startCell.":".$endCell; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | public function writeSheet(array $data, $sheet_name = '', array $header_types = array()) |
@@ -420,24 +420,24 @@ discard block |
||
420 | 420 | $cell_name = self::xlsCell($row_number, $column_number); |
421 | 421 | |
422 | 422 | if (!is_scalar($value) || $value === '') { //objects, array, empty |
423 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '"/>'); |
|
423 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'"/>'); |
|
424 | 424 | } elseif (is_string($value) && $value{0} == '=') { |
425 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '" t="s"><f>' . self::xmlspecialchars($value) . '</f></c>'); |
|
425 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="s"><f>'.self::xmlspecialchars($value).'</f></c>'); |
|
426 | 426 | } elseif ($num_format_type == 'n_date') { |
427 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '" t="n"><v>' . intval(self::convert_date_time($value)) . '</v></c>'); |
|
427 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.intval(self::convert_date_time($value)).'</v></c>'); |
|
428 | 428 | } elseif ($num_format_type == 'n_datetime') { |
429 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '" t="n"><v>' . self::convert_date_time($value) . '</v></c>'); |
|
429 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::convert_date_time($value).'</v></c>'); |
|
430 | 430 | } elseif ($num_format_type == 'n_numeric') { |
431 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '" t="n"><v>' . self::xmlspecialchars($value) . '</v></c>');//int,float,currency |
|
431 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>'); //int,float,currency |
|
432 | 432 | } elseif ($num_format_type == 'n_string') { |
433 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '" t="inlineStr"><is><t>' . self::xmlspecialchars($value) . '</t></is></c>'); |
|
433 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>'); |
|
434 | 434 | } elseif ($num_format_type == 'n_auto' || 1) { //auto-detect unknown column types |
435 | 435 | if (!is_string($value) || $value == '0' || ($value[0] != '0' && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", |
436 | 436 | $value) |
437 | 437 | ) { |
438 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '" t="n"><v>' . self::xmlspecialchars($value) . '</v></c>');//int,float,currency |
|
438 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>'); //int,float,currency |
|
439 | 439 | } else { //implied: ($cell_format=='string') |
440 | - $file->write('<c r="' . $cell_name . '" s="' . $cell_style_idx . '" t="inlineStr"><is><t>' . self::xmlspecialchars($value) . '</t></is></c>'); |
|
440 | + $file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>'); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | } |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | static $horizontal_allowed = array('general', 'left', 'right', 'justify', 'center'); |
464 | 464 | static $vertical_allowed = array('bottom', 'center', 'distributed', 'top'); |
465 | 465 | $default_font = array('size' => '10', 'name' => 'Arial', 'family' => '2'); |
466 | - $fills = array('', '');//2 placeholders for static xml later |
|
467 | - $fonts = array('', '', '', '');//4 placeholders for static xml later |
|
468 | - $borders = array('');//1 placeholder for static xml later |
|
466 | + $fills = array('', ''); //2 placeholders for static xml later |
|
467 | + $fonts = array('', '', '', ''); //4 placeholders for static xml later |
|
468 | + $borders = array(''); //1 placeholder for static xml later |
|
469 | 469 | $style_indexes = array(); |
470 | 470 | foreach ($this->cell_styles as $i => $cell_style_string) { |
471 | 471 | $semi_colon_pos = strpos($cell_style_string, ";"); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $style_json_string = substr($cell_style_string, $semi_colon_pos + 1); |
474 | 474 | $style = @json_decode($style_json_string, $as_assoc = true); |
475 | 475 | |
476 | - $style_indexes[$i] = array('num_fmt_idx' => $number_format_idx);//initialize entry |
|
476 | + $style_indexes[$i] = array('num_fmt_idx' => $number_format_idx); //initialize entry |
|
477 | 477 | if (isset($style['border']) && is_string($style['border']))//border is a comma delimited str |
478 | 478 | { |
479 | 479 | $border_value['side'] = array_intersect(explode(",", $style['border']), $border_allowed); |
@@ -482,15 +482,15 @@ discard block |
||
482 | 482 | } |
483 | 483 | if (isset($style['border-color']) && is_string($style['border-color']) && $style['border-color'][0] == '#') { |
484 | 484 | $v = substr($style['border-color'], 1, 6); |
485 | - $v = strlen($v) == 3 ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v;// expand cf0 => ccff00 |
|
486 | - $border_value['color'] = "FF" . strtoupper($v); |
|
485 | + $v = strlen($v) == 3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00 |
|
486 | + $border_value['color'] = "FF".strtoupper($v); |
|
487 | 487 | } |
488 | 488 | $style_indexes[$i]['border_idx'] = self::add_to_list_get_index($borders, json_encode($border_value)); |
489 | 489 | } |
490 | 490 | if (isset($style['fill']) && is_string($style['fill']) && $style['fill'][0] == '#') { |
491 | 491 | $v = substr($style['fill'], 1, 6); |
492 | - $v = strlen($v) == 3 ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v;// expand cf0 => ccff00 |
|
493 | - $style_indexes[$i]['fill_idx'] = self::add_to_list_get_index($fills, "FF" . strtoupper($v)); |
|
492 | + $v = strlen($v) == 3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00 |
|
493 | + $style_indexes[$i]['fill_idx'] = self::add_to_list_get_index($fills, "FF".strtoupper($v)); |
|
494 | 494 | } |
495 | 495 | if (isset($style['halign']) && in_array($style['halign'], $horizontal_allowed)) { |
496 | 496 | $style_indexes[$i]['alignment'] = true; |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | } |
503 | 503 | if (isset($style['wrap_text'])) { |
504 | 504 | $style_indexes[$i]['alignment'] = true; |
505 | - $style_indexes[$i]['wrap_text'] = (bool)$style['wrap_text']; |
|
505 | + $style_indexes[$i]['wrap_text'] = (bool) $style['wrap_text']; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | $font = $default_font; |
509 | 509 | if (isset($style['font-size'])) { |
510 | - $font['size'] = floatval($style['font-size']);//floatval to allow "10.5" etc |
|
510 | + $font['size'] = floatval($style['font-size']); //floatval to allow "10.5" etc |
|
511 | 511 | } |
512 | 512 | if (isset($style['font']) && is_string($style['font'])) { |
513 | 513 | if ($style['font'] == 'Comic Sans MS') { |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | } |
538 | 538 | if (isset($style['color']) && is_string($style['color']) && $style['color'][0] == '#') { |
539 | 539 | $v = substr($style['color'], 1, 6); |
540 | - $v = strlen($v) == 3 ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v;// expand cf0 => ccff00 |
|
541 | - $font['color'] = "FF" . strtoupper($v); |
|
540 | + $v = strlen($v) == 3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00 |
|
541 | + $font['color'] = "FF".strtoupper($v); |
|
542 | 542 | } |
543 | 543 | if ($font != $default_font) { |
544 | 544 | $style_indexes[$i]['font_idx'] = self::add_to_list_get_index($fonts, json_encode($font)); |
@@ -557,11 +557,11 @@ discard block |
||
557 | 557 | |
558 | 558 | $temporary_filename = $this->tempFilename(); |
559 | 559 | $file = new XLSXWriter_BuffererWriter($temporary_filename); |
560 | - $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"); |
|
560 | + $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"); |
|
561 | 561 | $file->write('<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'); |
562 | - $file->write('<numFmts count="' . count($this->number_formats) . '">'); |
|
562 | + $file->write('<numFmts count="'.count($this->number_formats).'">'); |
|
563 | 563 | foreach ($this->number_formats as $i => $v) { |
564 | - $file->write('<numFmt numFmtId="' . (164 + $i) . '" formatCode="' . self::xmlspecialchars($v) . '" />'); |
|
564 | + $file->write('<numFmt numFmtId="'.(164 + $i).'" formatCode="'.self::xmlspecialchars($v).'" />'); |
|
565 | 565 | } |
566 | 566 | //$file->write( '<numFmt formatCode="GENERAL" numFmtId="164"/>'); |
567 | 567 | //$file->write( '<numFmt formatCode="[$$-1009]#,##0.00;[RED]\-[$$-1009]#,##0.00" numFmtId="165"/>'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | //$file->write( '<numFmt formatCode="YYYY-MM-DD" numFmtId="167"/>'); |
570 | 570 | $file->write('</numFmts>'); |
571 | 571 | |
572 | - $file->write('<fonts count="' . (count($fonts)) . '">'); |
|
572 | + $file->write('<fonts count="'.(count($fonts)).'">'); |
|
573 | 573 | $file->write('<font><name val="Arial"/><charset val="1"/><family val="2"/><sz val="10"/></font>'); |
574 | 574 | $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>'); |
575 | 575 | $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>'); |
@@ -579,10 +579,10 @@ discard block |
||
579 | 579 | if (!empty($font)) { //fonts have 4 empty placeholders in array to offset the 4 static xml entries above |
580 | 580 | $f = json_decode($font, true); |
581 | 581 | $file->write('<font>'); |
582 | - $file->write('<name val="' . htmlspecialchars($f['name']) . '"/><charset val="1"/><family val="' . intval($f['family']) . '"/>'); |
|
583 | - $file->write('<sz val="' . intval($f['size']) . '"/>'); |
|
582 | + $file->write('<name val="'.htmlspecialchars($f['name']).'"/><charset val="1"/><family val="'.intval($f['family']).'"/>'); |
|
583 | + $file->write('<sz val="'.intval($f['size']).'"/>'); |
|
584 | 584 | if (!empty($f['color'])) { |
585 | - $file->write('<color rgb="' . strval($f['color']) . '"/>'); |
|
585 | + $file->write('<color rgb="'.strval($f['color']).'"/>'); |
|
586 | 586 | } |
587 | 587 | if (!empty($f['bold'])) { |
588 | 588 | $file->write('<b val="true"/>'); |
@@ -601,23 +601,23 @@ discard block |
||
601 | 601 | } |
602 | 602 | $file->write('</fonts>'); |
603 | 603 | |
604 | - $file->write('<fills count="' . (count($fills)) . '">'); |
|
604 | + $file->write('<fills count="'.(count($fills)).'">'); |
|
605 | 605 | $file->write('<fill><patternFill patternType="none"/></fill>'); |
606 | 606 | $file->write('<fill><patternFill patternType="gray125"/></fill>'); |
607 | 607 | foreach ($fills as $fill) { |
608 | 608 | if (!empty($fill)) { //fills have 2 empty placeholders in array to offset the 2 static xml entries above |
609 | - $file->write('<fill><patternFill patternType="solid"><fgColor rgb="' . strval($fill) . '"/><bgColor indexed="64"/></patternFill></fill>'); |
|
609 | + $file->write('<fill><patternFill patternType="solid"><fgColor rgb="'.strval($fill).'"/><bgColor indexed="64"/></patternFill></fill>'); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | $file->write('</fills>'); |
613 | 613 | |
614 | - $file->write('<borders count="' . (count($borders)) . '">'); |
|
614 | + $file->write('<borders count="'.(count($borders)).'">'); |
|
615 | 615 | $file->write('<border diagonalDown="false" diagonalUp="false"><left/><right/><top/><bottom/><diagonal/></border>'); |
616 | 616 | foreach ($borders as $border) { |
617 | 617 | if (!empty($border)) { //fonts have an empty placeholder in the array to offset the static xml entry above |
618 | 618 | $pieces = json_decode($border, true); |
619 | 619 | $border_style = !empty($pieces['style']) ? $pieces['style'] : 'hair'; |
620 | - $border_color = !empty($pieces['color']) ? '<color rgb="' . strval($pieces['color']) . '"/>' : ''; |
|
620 | + $border_color = !empty($pieces['color']) ? '<color rgb="'.strval($pieces['color']).'"/>' : ''; |
|
621 | 621 | $file->write('<border diagonalDown="false" diagonalUp="false">'); |
622 | 622 | foreach (array('left', 'right', 'top', 'bottom') as $side) { |
623 | 623 | $show_side = in_array($side, $pieces['side']) ? true : false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | $file->write('<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="9"/>'); |
656 | 656 | $file->write('</cellStyleXfs>'); |
657 | 657 | |
658 | - $file->write('<cellXfs count="' . (count($style_indexes)) . '">'); |
|
658 | + $file->write('<cellXfs count="'.(count($style_indexes)).'">'); |
|
659 | 659 | //$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="164" xfId="0"/>'); |
660 | 660 | //$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="165" xfId="0"/>'); |
661 | 661 | //$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="166" xfId="0"/>'); |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | $fillIdx = isset($v['fill_idx']) ? intval($v['fill_idx']) : 0; |
672 | 672 | $fontIdx = isset($v['font_idx']) ? intval($v['font_idx']) : 0; |
673 | 673 | //$file->write('<xf applyAlignment="'.$applyAlignment.'" applyBorder="'.$applyBorder.'" applyFont="'.$applyFont.'" applyProtection="false" borderId="'.($borderIdx).'" fillId="'.($fillIdx).'" fontId="'.($fontIdx).'" numFmtId="'.(164+$v['num_fmt_idx']).'" xfId="0"/>'); |
674 | - $file->write('<xf applyAlignment="' . $applyAlignment . '" applyBorder="' . $applyBorder . '" applyFont="' . $applyFont . '" applyProtection="false" borderId="' . ($borderIdx) . '" fillId="' . ($fillIdx) . '" fontId="' . ($fontIdx) . '" numFmtId="' . (164 + $v['num_fmt_idx']) . '" xfId="0">'); |
|
675 | - $file->write(' <alignment horizontal="' . $horizAlignment . '" vertical="' . $vertAlignment . '" textRotation="0" wrapText="' . $wrapText . '" indent="0" shrinkToFit="false"/>'); |
|
674 | + $file->write('<xf applyAlignment="'.$applyAlignment.'" applyBorder="'.$applyBorder.'" applyFont="'.$applyFont.'" applyProtection="false" borderId="'.($borderIdx).'" fillId="'.($fillIdx).'" fontId="'.($fontIdx).'" numFmtId="'.(164 + $v['num_fmt_idx']).'" xfId="0">'); |
|
675 | + $file->write(' <alignment horizontal="'.$horizAlignment.'" vertical="'.$vertAlignment.'" textRotation="0" wrapText="'.$wrapText.'" indent="0" shrinkToFit="false"/>'); |
|
676 | 676 | $file->write(' <protection locked="true" hidden="false"/>'); |
677 | 677 | $file->write('</xf>'); |
678 | 678 | } |
@@ -693,10 +693,10 @@ discard block |
||
693 | 693 | protected function buildAppXML() |
694 | 694 | { |
695 | 695 | $app_xml = ""; |
696 | - $app_xml .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"; |
|
696 | + $app_xml .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"; |
|
697 | 697 | $app_xml .= '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">'; |
698 | 698 | $app_xml .= '<TotalTime>0</TotalTime>'; |
699 | - $app_xml .= '<Company>' . self::xmlspecialchars($this->company) . '</Company>'; |
|
699 | + $app_xml .= '<Company>'.self::xmlspecialchars($this->company).'</Company>'; |
|
700 | 700 | $app_xml .= '</Properties>'; |
701 | 701 | return $app_xml; |
702 | 702 | } |
@@ -704,17 +704,17 @@ discard block |
||
704 | 704 | protected function buildCoreXML() |
705 | 705 | { |
706 | 706 | $core_xml = ""; |
707 | - $core_xml .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"; |
|
707 | + $core_xml .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"; |
|
708 | 708 | $core_xml .= '<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'; |
709 | - $core_xml .= '<dcterms:created xsi:type="dcterms:W3CDTF">' . date("Y-m-d\TH:i:s.00\Z") . '</dcterms:created>';//$date_time = '2014-10-25T15:54:37.00Z'; |
|
710 | - $core_xml .= '<dc:title>' . self::xmlspecialchars($this->title) . '</dc:title>'; |
|
711 | - $core_xml .= '<dc:subject>' . self::xmlspecialchars($this->subject) . '</dc:subject>'; |
|
712 | - $core_xml .= '<dc:creator>' . self::xmlspecialchars($this->author) . '</dc:creator>'; |
|
709 | + $core_xml .= '<dcterms:created xsi:type="dcterms:W3CDTF">'.date("Y-m-d\TH:i:s.00\Z").'</dcterms:created>'; //$date_time = '2014-10-25T15:54:37.00Z'; |
|
710 | + $core_xml .= '<dc:title>'.self::xmlspecialchars($this->title).'</dc:title>'; |
|
711 | + $core_xml .= '<dc:subject>'.self::xmlspecialchars($this->subject).'</dc:subject>'; |
|
712 | + $core_xml .= '<dc:creator>'.self::xmlspecialchars($this->author).'</dc:creator>'; |
|
713 | 713 | if (!empty($this->keywords)) { |
714 | - $core_xml .= '<cp:keywords>' . self::xmlspecialchars(implode(", ", |
|
715 | - (array)$this->keywords)) . '</cp:keywords>'; |
|
714 | + $core_xml .= '<cp:keywords>'.self::xmlspecialchars(implode(", ", |
|
715 | + (array) $this->keywords)).'</cp:keywords>'; |
|
716 | 716 | } |
717 | - $core_xml .= '<dc:description>' . self::xmlspecialchars($this->description) . '</dc:description>'; |
|
717 | + $core_xml .= '<dc:description>'.self::xmlspecialchars($this->description).'</dc:description>'; |
|
718 | 718 | $core_xml .= '<cp:revision>0</cp:revision>'; |
719 | 719 | $core_xml .= '</cp:coreProperties>'; |
720 | 720 | return $core_xml; |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | protected function buildRelationshipsXML() |
724 | 724 | { |
725 | 725 | $rels_xml = ""; |
726 | - $rels_xml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
|
726 | + $rels_xml .= '<?xml version="1.0" encoding="UTF-8"?>'."\n"; |
|
727 | 727 | $rels_xml .= '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'; |
728 | 728 | $rels_xml .= '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'; |
729 | 729 | $rels_xml .= '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>'; |
@@ -737,14 +737,14 @@ discard block |
||
737 | 737 | { |
738 | 738 | $i = 0; |
739 | 739 | $workbook_xml = ""; |
740 | - $workbook_xml .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"; |
|
740 | + $workbook_xml .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"; |
|
741 | 741 | $workbook_xml .= '<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'; |
742 | 742 | $workbook_xml .= '<fileVersion appName="Calc"/><workbookPr backupFile="false" showObjects="all" date1904="false"/><workbookProtection/>'; |
743 | 743 | $workbook_xml .= '<bookViews><workbookView activeTab="0" firstSheet="0" showHorizontalScroll="true" showSheetTabs="true" showVerticalScroll="true" tabRatio="212" windowHeight="8192" windowWidth="16384" xWindow="0" yWindow="0"/></bookViews>'; |
744 | 744 | $workbook_xml .= '<sheets>'; |
745 | 745 | foreach ($this->sheets as $sheet_name => $sheet) { |
746 | 746 | $sheetname = self::sanitize_sheetname($sheet->sheetname); |
747 | - $workbook_xml .= '<sheet name="' . self::xmlspecialchars($sheetname) . '" sheetId="' . ($i + 1) . '" state="visible" r:id="rId' . ($i + 2) . '"/>'; |
|
747 | + $workbook_xml .= '<sheet name="'.self::xmlspecialchars($sheetname).'" sheetId="'.($i + 1).'" state="visible" r:id="rId'.($i + 2).'"/>'; |
|
748 | 748 | $i++; |
749 | 749 | } |
750 | 750 | $workbook_xml .= '</sheets>'; |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | foreach ($this->sheets as $sheet_name => $sheet) { |
753 | 753 | if ($sheet->auto_filter) { |
754 | 754 | $sheetname = self::sanitize_sheetname($sheet->sheetname); |
755 | - $workbook_xml .= '<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\'' . self::xmlspecialchars($sheetname) . '\'!$A$1:' . self::xlsCell($sheet->row_count - 1, |
|
756 | - count($sheet->columns) - 1, true) . '</definedName>'; |
|
755 | + $workbook_xml .= '<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\''.self::xmlspecialchars($sheetname).'\'!$A$1:'.self::xlsCell($sheet->row_count - 1, |
|
756 | + count($sheet->columns) - 1, true).'</definedName>'; |
|
757 | 757 | $i++; |
758 | 758 | } |
759 | 759 | } |
@@ -766,11 +766,11 @@ discard block |
||
766 | 766 | { |
767 | 767 | $i = 0; |
768 | 768 | $wkbkrels_xml = ""; |
769 | - $wkbkrels_xml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
|
769 | + $wkbkrels_xml .= '<?xml version="1.0" encoding="UTF-8"?>'."\n"; |
|
770 | 770 | $wkbkrels_xml .= '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'; |
771 | 771 | $wkbkrels_xml .= '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'; |
772 | 772 | foreach ($this->sheets as $sheet_name => $sheet) { |
773 | - $wkbkrels_xml .= '<Relationship Id="rId' . ($i + 2) . '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/' . ($sheet->xmlname) . '"/>'; |
|
773 | + $wkbkrels_xml .= '<Relationship Id="rId'.($i + 2).'" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/'.($sheet->xmlname).'"/>'; |
|
774 | 774 | $i++; |
775 | 775 | } |
776 | 776 | $wkbkrels_xml .= "\n"; |
@@ -781,12 +781,12 @@ discard block |
||
781 | 781 | protected function buildContentTypesXML() |
782 | 782 | { |
783 | 783 | $content_types_xml = ""; |
784 | - $content_types_xml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
|
784 | + $content_types_xml .= '<?xml version="1.0" encoding="UTF-8"?>'."\n"; |
|
785 | 785 | $content_types_xml .= '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'; |
786 | 786 | $content_types_xml .= '<Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'; |
787 | 787 | $content_types_xml .= '<Override PartName="/xl/_rels/workbook.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'; |
788 | 788 | foreach ($this->sheets as $sheet_name => $sheet) { |
789 | - $content_types_xml .= '<Override PartName="/xl/worksheets/' . ($sheet->xmlname) . '" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>'; |
|
789 | + $content_types_xml .= '<Override PartName="/xl/worksheets/'.($sheet->xmlname).'" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>'; |
|
790 | 790 | } |
791 | 791 | $content_types_xml .= '<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>'; |
792 | 792 | $content_types_xml .= '<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'; |
@@ -808,19 +808,19 @@ discard block |
||
808 | 808 | { |
809 | 809 | $n = $column_number; |
810 | 810 | for ($r = ""; $n >= 0; $n = intval($n / 26) - 1) { |
811 | - $r = chr($n % 26 + 0x41) . $r; |
|
811 | + $r = chr($n % 26 + 0x41).$r; |
|
812 | 812 | } |
813 | 813 | if ($absolute) { |
814 | - return '$' . $r . '$' . ($row_number + 1); |
|
814 | + return '$'.$r.'$'.($row_number + 1); |
|
815 | 815 | } |
816 | - return $r . ($row_number + 1); |
|
816 | + return $r.($row_number + 1); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | //------------------------------------------------------------------ |
820 | 820 | public static function log($string) |
821 | 821 | { |
822 | 822 | file_put_contents("php://stderr", |
823 | - date("Y-m-d H:i:s:") . rtrim(is_array($string) ? json_encode($string) : $string) . "\n"); |
|
823 | + date("Y-m-d H:i:s:").rtrim(is_array($string) ? json_encode($string) : $string)."\n"); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | //------------------------------------------------------------------ |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | static $goodchars = ' '; |
841 | 841 | $sheetname = strtr($sheetname, $badchars, $goodchars); |
842 | 842 | $sheetname = substr($sheetname, 0, 31); |
843 | - $sheetname = trim(trim(trim($sheetname), "'"));//trim before and after trimming single quotes |
|
844 | - return !empty($sheetname) ? $sheetname : 'Sheet' . ((rand() % 900) + 100); |
|
843 | + $sheetname = trim(trim(trim($sheetname), "'")); //trim before and after trimming single quotes |
|
844 | + return !empty($sheetname) ? $sheetname : 'Sheet'.((rand() % 900) + 100); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | //------------------------------------------------------------------ |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | static $badchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"; |
852 | 852 | static $goodchars = " "; |
853 | 853 | return strtr(htmlspecialchars($val, ENT_QUOTES | ENT_XML1), $badchars, |
854 | - $goodchars);//strtr appears to be faster than str_replace |
|
854 | + $goodchars); //strtr appears to be faster than str_replace |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | //------------------------------------------------------------------ |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | } |
956 | 956 | } |
957 | 957 | if ($ignore_until == '' && ($c == ' ' || $c == '-' || $c == '(' || $c == ')') && ($i == 0 || $num_format[$i - 1] != '_')) { |
958 | - $escaped .= "\\" . $c; |
|
958 | + $escaped .= "\\".$c; |
|
959 | 959 | } else { |
960 | 960 | $escaped .= $c; |
961 | 961 | } |
@@ -977,8 +977,8 @@ discard block |
||
977 | 977 | //------------------------------------------------------------------ |
978 | 978 | public static function convert_date_time($date_input) //thanks to Excel::Writer::XLSX::Worksheet.pm (perl) |
979 | 979 | { |
980 | - $days = 0; # Number of days since epoch |
|
981 | - $seconds = 0; # Time expressed as fraction of 24h hours in seconds |
|
980 | + $days = 0; # Number of days since epoch |
|
981 | + $seconds = 0; # Time expressed as fraction of 24h hours in seconds |
|
982 | 982 | $year = $month = $day = 0; |
983 | 983 | $hour = $min = $sec = 0; |
984 | 984 | |
@@ -1029,13 +1029,13 @@ discard block |
||
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | # Accumulate the number of days since the epoch. |
1032 | - $days = $day; # Add days for current month |
|
1033 | - $days += array_sum(array_slice($mdays, 0, $month - 1)); # Add days for past months |
|
1034 | - $days += $range * 365; # Add days for past years |
|
1035 | - $days += intval(($range) / 4); # Add leapdays |
|
1032 | + $days = $day; # Add days for current month |
|
1033 | + $days += array_sum(array_slice($mdays, 0, $month - 1)); # Add days for past months |
|
1034 | + $days += $range * 365; # Add days for past years |
|
1035 | + $days += intval(($range) / 4); # Add leapdays |
|
1036 | 1036 | $days -= intval(($range + $offset) / 100); # Subtract 100 year leapdays |
1037 | - $days += intval(($range + $offset + $norm) / 400); # Add 400 year leapdays |
|
1038 | - $days -= $leap; # Already counted above |
|
1037 | + $days += intval(($range + $offset + $norm) / 400); # Add 400 year leapdays |
|
1038 | + $days -= $leap; # Already counted above |
|
1039 | 1039 | |
1040 | 1040 | # Adjust for Excel erroneously treating 1900 as a leap year. |
1041 | 1041 | if ($days > 59) { |
@@ -474,9 +474,11 @@ |
||
474 | 474 | $style = @json_decode($style_json_string, $as_assoc = true); |
475 | 475 | |
476 | 476 | $style_indexes[$i] = array('num_fmt_idx' => $number_format_idx);//initialize entry |
477 | - if (isset($style['border']) && is_string($style['border']))//border is a comma delimited str |
|
477 | + if (isset($style['border']) && is_string($style['border'])) { |
|
478 | + //border is a comma delimited str |
|
478 | 479 | { |
479 | 480 | $border_value['side'] = array_intersect(explode(",", $style['border']), $border_allowed); |
481 | + } |
|
480 | 482 | if (isset($style['border-style']) && in_array($style['border-style'], $border_style_allowed)) { |
481 | 483 | $border_value['style'] = $style['border-style']; |
482 | 484 | } |