@@ -39,13 +39,13 @@ |
||
| 39 | 39 | yield ['sheet_name_1', [ |
| 40 | 40 | 'title' . $i, |
| 41 | 41 | 'content' . $i, |
| 42 | - $i+$i, |
|
| 42 | + $i + $i, |
|
| 43 | 43 | ]]; |
| 44 | 44 | } else { |
| 45 | 45 | yield ['sheet_name_2', [ |
| 46 | 46 | 'title' . $i, |
| 47 | 47 | 'content' . $i, |
| 48 | - $i+$i, |
|
| 48 | + $i + $i, |
|
| 49 | 49 | ]]; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -63,28 +63,28 @@ discard block |
||
| 63 | 63 | $cellName = Support::xlsCell($rowNumber, $columnNumber); |
| 64 | 64 | $file = $this->getFileWriter(); |
| 65 | 65 | if (!is_scalar($value) || '' === $value) { //objects, array, empty |
| 66 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'"/>'); |
|
| 66 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '"/>'); |
|
| 67 | 67 | } elseif (is_string($value) && '=' == $value[0]) { |
| 68 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="s"><f>'.Support::xmlSpecialChars($value).'</f></c>'); |
|
| 68 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="s"><f>' . Support::xmlSpecialChars($value) . '</f></c>'); |
|
| 69 | 69 | } else { |
| 70 | 70 | switch ($numFormatType) { |
| 71 | 71 | case 'n_date': |
| 72 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
| 73 | - intval(Support::convertDateTime($value)).'</v></c>'); |
|
| 72 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
| 73 | + intval(Support::convertDateTime($value)) . '</v></c>'); |
|
| 74 | 74 | |
| 75 | 75 | break; |
| 76 | 76 | case 'n_datetime': |
| 77 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
| 78 | - Support::convertDateTime($value).'</v></c>'); |
|
| 77 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
| 78 | + Support::convertDateTime($value) . '</v></c>'); |
|
| 79 | 79 | |
| 80 | 80 | break; |
| 81 | 81 | case 'n_numeric': |
| 82 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
| 83 | - Support::xmlSpecialChars($value).'</v></c>'); //int,float,currency |
|
| 82 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
| 83 | + Support::xmlSpecialChars($value) . '</v></c>'); //int,float,currency |
|
| 84 | 84 | break; |
| 85 | 85 | case 'n_string': |
| 86 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'. |
|
| 87 | - Support::xmlSpecialChars($value).'</t></is></c>'); |
|
| 86 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' . |
|
| 87 | + Support::xmlSpecialChars($value) . '</t></is></c>'); |
|
| 88 | 88 | |
| 89 | 89 | break; |
| 90 | 90 | case 'n_auto': |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | if (!is_string($value) || '0' == $value || ('0' != $value[0] && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", $value) |
| 93 | 93 | ) { //int,float,currency |
| 94 | 94 | $file->write( |
| 95 | - '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
| 96 | - Support::xmlSpecialChars($value).'</v></c>' |
|
| 95 | + '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
| 96 | + Support::xmlSpecialChars($value) . '</v></c>' |
|
| 97 | 97 | ); |
| 98 | 98 | } else { //implied: ($cell_format=='string') |
| 99 | 99 | $file->write( |
| 100 | - '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'. |
|
| 101 | - Support::xmlSpecialChars($value).'</t></is></c>' |
|
| 100 | + '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' . |
|
| 101 | + Support::xmlSpecialChars($value) . '</t></is></c>' |
|
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | $writer = $this->getFileWriter(); |
| 117 | 117 | $tabSelected = $isTabSelected ? 'true' : 'false'; |
| 118 | 118 | $maxCell = Support::xlsCell(Builder::EXCEL_2007_MAX_ROW, Builder::EXCEL_2007_MAX_COL); //XFE1048577 |
| 119 | - $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"); |
|
| 119 | + $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"); |
|
| 120 | 120 | $writer->write( |
| 121 | 121 | <<<'EOF' |
| 122 | 122 | <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheetPr filterMode="false"><pageSetUpPr fitToPage="false"/></sheetPr> |
| 123 | 123 | EOF |
| 124 | 124 | ); |
| 125 | 125 | $this->maxCellTagStart = $this->fileWriter->ftell(); |
| 126 | - $writer->write('<dimension ref="A1:'.$maxCell.'"/>'); |
|
| 126 | + $writer->write('<dimension ref="A1:' . $maxCell . '"/>'); |
|
| 127 | 127 | $this->maxCellTagEnd = $this->fileWriter->ftell(); |
| 128 | 128 | $writer->write('<sheetViews>'); |
| 129 | 129 | $writer->write( |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | if (!empty($colWidths)) { |
| 146 | 146 | foreach ($colWidths as $colWidth) { |
| 147 | 147 | $writer->write( |
| 148 | - '<col collapsed="false" hidden="false" max="'.($i + 1).'" min="'.($i + 1). |
|
| 149 | - '" style="0" customWidth="true" width="'.floatval($colWidth).'"/>' |
|
| 148 | + '<col collapsed="false" hidden="false" max="' . ($i + 1) . '" min="' . ($i + 1) . |
|
| 149 | + '" style="0" customWidth="true" width="' . floatval($colWidth) . '"/>' |
|
| 150 | 150 | ); |
| 151 | 151 | ++$i; |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | $writer->write( |
| 155 | - '<col collapsed="false" hidden="false" max="1024" min="'.($i + 1). |
|
| 156 | - '" style="0" customWidth="false" width="11.5"/>'.'</cols><sheetData>' |
|
| 155 | + '<col collapsed="false" hidden="false" max="1024" min="' . ($i + 1) . |
|
| 156 | + '" style="0" customWidth="false" width="11.5"/>' . '</cols><sheetData>' |
|
| 157 | 157 | ); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | if (!empty($this->merge_cells)) { |
| 165 | 165 | $this->fileWriter->write('<mergeCells>'); |
| 166 | 166 | foreach ($this->mergeCells as $range) { |
| 167 | - $this->fileWriter->write('<mergeCell ref="'.$range.'"/>'); |
|
| 167 | + $this->fileWriter->write('<mergeCell ref="' . $range . '"/>'); |
|
| 168 | 168 | } |
| 169 | 169 | $this->fileWriter->write('</mergeCells>'); |
| 170 | 170 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $max_cell = Support::xlsCell($this->rowCount - 1, count($this->columns) - 1); |
| 173 | 173 | |
| 174 | 174 | if ($this->autoFilter) { |
| 175 | - $this->fileWriter->write('<autoFilter ref="A1:'.$max_cell.'"/>'); |
|
| 175 | + $this->fileWriter->write('<autoFilter ref="A1:' . $max_cell . '"/>'); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $this->fileWriter->write('<printOptions headings="false" gridLines="false" gridLinesSet="true" horizontalCentered="false" verticalCentered="false"/>'); |
@@ -184,10 +184,10 @@ discard block |
||
| 184 | 184 | $this->fileWriter->write('</headerFooter>'); |
| 185 | 185 | $this->fileWriter->write('</worksheet>'); |
| 186 | 186 | |
| 187 | - $max_cell_tag = '<dimension ref="A1:'.$max_cell.'"/>'; |
|
| 187 | + $max_cell_tag = '<dimension ref="A1:' . $max_cell . '"/>'; |
|
| 188 | 188 | $padding_length = $this->maxCellTagEnd - $this->maxCellTagStart - strlen($max_cell_tag); |
| 189 | 189 | $this->fileWriter->fseek($this->maxCellTagStart); |
| 190 | - $this->fileWriter->write($max_cell_tag.str_repeat(' ', $padding_length)); |
|
| 190 | + $this->fileWriter->write($max_cell_tag . str_repeat(' ', $padding_length)); |
|
| 191 | 191 | $this->fileWriter->close(); |
| 192 | 192 | $this->finalized = true; |
| 193 | 193 | } |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | $writer = $this->getFileWriter(); |
| 198 | 198 | $writer->write( |
| 199 | - '<pane ySplit="'.$this->freezeRows.'" xSplit="'.$this->freezeColumns. |
|
| 200 | - '" topLeftCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns). |
|
| 201 | - '" activePane="bottomRight" state="frozen"/>'.'<selection activeCell="'.Support::xlsCell($this->freezeRows, 0). |
|
| 202 | - '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>'. |
|
| 203 | - '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns). |
|
| 204 | - '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>'. |
|
| 205 | - '<selection activeCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns). |
|
| 206 | - '" activeCellId="0" pane="bottomRight" sqref="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).'"/>' |
|
| 199 | + '<pane ySplit="' . $this->freezeRows . '" xSplit="' . $this->freezeColumns . |
|
| 200 | + '" topLeftCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . |
|
| 201 | + '" activePane="bottomRight" state="frozen"/>' . '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) . |
|
| 202 | + '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>' . |
|
| 203 | + '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) . |
|
| 204 | + '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>' . |
|
| 205 | + '<selection activeCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . |
|
| 206 | + '" activeCellId="0" pane="bottomRight" sqref="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . '"/>' |
|
| 207 | 207 | ); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -211,10 +211,10 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | $writer = $this->getFileWriter(); |
| 213 | 213 | $writer->write( |
| 214 | - '<pane ySplit="'.$this->freezeRows.'" topLeftCell="'. |
|
| 215 | - Support::xlsCell($this->freezeRows, 0).'" activePane="bottomLeft" state="frozen"/>'. |
|
| 216 | - '<selection activeCell="'.Support::xlsCell($this->freezeRows, 0). |
|
| 217 | - '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>' |
|
| 214 | + '<pane ySplit="' . $this->freezeRows . '" topLeftCell="' . |
|
| 215 | + Support::xlsCell($this->freezeRows, 0) . '" activePane="bottomLeft" state="frozen"/>' . |
|
| 216 | + '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) . |
|
| 217 | + '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>' |
|
| 218 | 218 | ); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $writer = $this->getFileWriter(); |
| 224 | 224 | $writer->write( |
| 225 | - '<pane xSplit="'.$this->freezeColumns.'" topLeftCell="'. |
|
| 226 | - Support::xlsCell(0, $this->freezeColumns).'" activePane="topRight" state="frozen"/>'. |
|
| 227 | - '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns). |
|
| 228 | - '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>' |
|
| 225 | + '<pane xSplit="' . $this->freezeColumns . '" topLeftCell="' . |
|
| 226 | + Support::xlsCell(0, $this->freezeColumns) . '" activePane="topRight" state="frozen"/>' . |
|
| 227 | + '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) . |
|
| 228 | + '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>' |
|
| 229 | 229 | ); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | if (is_writable($filename)) { |
| 166 | 166 | @unlink($filename); //if the zip already exists, remove it |
| 167 | 167 | } else { |
| 168 | - throw new XlsxException('Error in '.__CLASS__.'::'.__FUNCTION__.', file is not writeable.'); |
|
| 168 | + throw new XlsxException('Error in ' . __CLASS__ . '::' . __FUNCTION__ . ', file is not writeable.'); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | $zip = new \ZipArchive(); |
| 172 | 172 | if (empty($this->sheets)) { |
| 173 | - throw new XlsxException('Error in '.__CLASS__.'::'.__FUNCTION__.', no worksheets defined.'); |
|
| 173 | + throw new XlsxException('Error in ' . __CLASS__ . '::' . __FUNCTION__ . ', no worksheets defined.'); |
|
| 174 | 174 | } |
| 175 | 175 | if (!$zip->open($filename, \ZipArchive::CREATE)) { |
| 176 | - throw new XlsxException('Error in '.__CLASS__.'::'.__FUNCTION__.', unable to create zip.'); |
|
| 176 | + throw new XlsxException('Error in ' . __CLASS__ . '::' . __FUNCTION__ . ', unable to create zip.'); |
|
| 177 | 177 | } |
| 178 | 178 | $zip->addEmptyDir('docProps/'); |
| 179 | 179 | $zip->addFromString('docProps/app.xml', XlsxBuilder::buildAppXML($this->company)); |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | $zip->addFromString('_rels/.rels', XlsxBuilder::buildRelationshipsXML()); |
| 189 | 189 | $zip->addEmptyDir('xl/worksheets/'); |
| 190 | 190 | foreach ($this->sheets as $sheet) { |
| 191 | - $zip->addFile($sheet->filename, 'xl/worksheets/'.$sheet->xmlname); |
|
| 191 | + $zip->addFile($sheet->filename, 'xl/worksheets/' . $sheet->xmlname); |
|
| 192 | 192 | } |
| 193 | 193 | $zip->addFromString('xl/workbook.xml', XlsxBuilder::buildWorkbookXML($this->sheets)); |
| 194 | - $zip->addFile($this->writeStylesXML(), 'xl/styles.xml'); //$zip->addFromString("xl/styles.xml", self::buildStylesXML() ); |
|
| 194 | + $zip->addFile($this->writeStylesXML(), 'xl/styles.xml'); //$zip->addFromString("xl/styles.xml", self::buildStylesXML() ); |
|
| 195 | 195 | $zip->addFromString('[Content_Types].xml', XlsxBuilder::buildContentTypesXML($this->sheets)); |
| 196 | 196 | $zip->addEmptyDir('xl/_rels/'); |
| 197 | 197 | $zip->addFromString('xl/_rels/workbook.xml.rels', XlsxBuilder::buildWorkbookRelsXML($this->sheets)); |
@@ -213,22 +213,22 @@ discard block |
||
| 213 | 213 | $sheet = $this->getSheet($sheetName); |
| 214 | 214 | if (count($sheet->columns) < count($row)) { |
| 215 | 215 | $defaultColumnTypes = $this->initColumnsTypes(array_fill($from = 0, count($row), 'GENERAL')); //will map to n_auto |
| 216 | - $sheet->columns = array_merge((array) $sheet->columns, $defaultColumnTypes); |
|
| 216 | + $sheet->columns = array_merge((array)$sheet->columns, $defaultColumnTypes); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | if (!empty($rowOptions)) { |
| 220 | 220 | $ht = isset($rowOptions['height']) ? floatval($rowOptions['height']) : 12.1; |
| 221 | 221 | $customHt = isset($rowOptions['height']) ? true : false; |
| 222 | - $hidden = isset($rowOptions['hidden']) ? (bool) ($rowOptions['hidden']) : false; |
|
| 223 | - $collapsed = isset($rowOptions['collapsed']) ? (bool) ($rowOptions['collapsed']) : false; |
|
| 222 | + $hidden = isset($rowOptions['hidden']) ? (bool)($rowOptions['hidden']) : false; |
|
| 223 | + $collapsed = isset($rowOptions['collapsed']) ? (bool)($rowOptions['collapsed']) : false; |
|
| 224 | 224 | $sheet->fileWriter->write( |
| 225 | - '<row collapsed="'.($collapsed).'" customFormat="false" customHeight="'.($customHt). |
|
| 226 | - '" hidden="'.($hidden).'" ht="'.($ht).'" outlineLevel="0" r="'.($sheet->rowCount + 1).'">' |
|
| 225 | + '<row collapsed="' . ($collapsed) . '" customFormat="false" customHeight="' . ($customHt) . |
|
| 226 | + '" hidden="' . ($hidden) . '" ht="' . ($ht) . '" outlineLevel="0" r="' . ($sheet->rowCount + 1) . '">' |
|
| 227 | 227 | ); |
| 228 | 228 | } else { |
| 229 | 229 | $sheet->fileWriter->write( |
| 230 | - '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'. |
|
| 231 | - ($sheet->rowCount + 1).'">' |
|
| 230 | + '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . |
|
| 231 | + ($sheet->rowCount + 1) . '">' |
|
| 232 | 232 | ); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -237,8 +237,7 @@ discard block |
||
| 237 | 237 | foreach ($row as $v) { |
| 238 | 238 | $numberFormat = $sheet->columns[$c]['number_format']; |
| 239 | 239 | $numberFormatType = $sheet->columns[$c]['number_format_type']; |
| 240 | - $cellStyleIdx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : |
|
| 241 | - $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style)); |
|
| 240 | + $cellStyleIdx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style)); |
|
| 242 | 241 | $sheet->writeCell($sheet->rowCount, $c, $v, $numberFormatType, $cellStyleIdx); |
| 243 | 242 | ++$c; |
| 244 | 243 | } |
@@ -274,14 +273,14 @@ discard block |
||
| 274 | 273 | |
| 275 | 274 | $temporaryFilename = $this->tempFilename(); |
| 276 | 275 | $file = new XlsxWriterBuffer($temporaryFilename); |
| 277 | - $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"); |
|
| 276 | + $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"); |
|
| 278 | 277 | $file->write('<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'); |
| 279 | - $file->write('<numFmts count="'.count($this->numberFormats).'">'); |
|
| 278 | + $file->write('<numFmts count="' . count($this->numberFormats) . '">'); |
|
| 280 | 279 | foreach ($this->numberFormats as $i => $v) { |
| 281 | - $file->write('<numFmt numFmtId="'.(164 + $i).'" formatCode="'.Support::xmlSpecialChars($v).'" />'); |
|
| 280 | + $file->write('<numFmt numFmtId="' . (164 + $i) . '" formatCode="' . Support::xmlSpecialChars($v) . '" />'); |
|
| 282 | 281 | } |
| 283 | 282 | $file->write('</numFmts>'); |
| 284 | - $file->write('<fonts count="'.(count($fonts)).'">'); |
|
| 283 | + $file->write('<fonts count="' . (count($fonts)) . '">'); |
|
| 285 | 284 | $file->write('<font><name val="Arial"/><charset val="1"/><family val="2"/><sz val="10"/></font>'); |
| 286 | 285 | $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>'); |
| 287 | 286 | $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>'); |
@@ -291,10 +290,10 @@ discard block |
||
| 291 | 290 | if (!empty($font)) { //fonts have 4 empty placeholders in array to offset the 4 static xml entries above |
| 292 | 291 | $f = json_decode($font, true); |
| 293 | 292 | $file->write('<font>'); |
| 294 | - $file->write('<name val="'.htmlspecialchars($f['name']).'"/><charset val="1"/><family val="'.intval($f['family']).'"/>'); |
|
| 295 | - $file->write('<sz val="'.intval($f['size']).'"/>'); |
|
| 293 | + $file->write('<name val="' . htmlspecialchars($f['name']) . '"/><charset val="1"/><family val="' . intval($f['family']) . '"/>'); |
|
| 294 | + $file->write('<sz val="' . intval($f['size']) . '"/>'); |
|
| 296 | 295 | if (!empty($f['color'])) { |
| 297 | - $file->write('<color rgb="'.strval($f['color']).'"/>'); |
|
| 296 | + $file->write('<color rgb="' . strval($f['color']) . '"/>'); |
|
| 298 | 297 | } |
| 299 | 298 | if (!empty($f['bold'])) { |
| 300 | 299 | $file->write('<b val="true"/>'); |
@@ -313,23 +312,23 @@ discard block |
||
| 313 | 312 | } |
| 314 | 313 | $file->write('</fonts>'); |
| 315 | 314 | |
| 316 | - $file->write('<fills count="'.(count($fills)).'">'); |
|
| 315 | + $file->write('<fills count="' . (count($fills)) . '">'); |
|
| 317 | 316 | $file->write('<fill><patternFill patternType="none"/></fill>'); |
| 318 | 317 | $file->write('<fill><patternFill patternType="gray125"/></fill>'); |
| 319 | 318 | foreach ($fills as $fill) { |
| 320 | 319 | if (!empty($fill)) { //fills have 2 empty placeholders in array to offset the 2 static xml entries above |
| 321 | - $file->write('<fill><patternFill patternType="solid"><fgColor rgb="'.strval($fill).'"/><bgColor indexed="64"/></patternFill></fill>'); |
|
| 320 | + $file->write('<fill><patternFill patternType="solid"><fgColor rgb="' . strval($fill) . '"/><bgColor indexed="64"/></patternFill></fill>'); |
|
| 322 | 321 | } |
| 323 | 322 | } |
| 324 | 323 | $file->write('</fills>'); |
| 325 | 324 | |
| 326 | - $file->write('<borders count="'.(count($borders)).'">'); |
|
| 325 | + $file->write('<borders count="' . (count($borders)) . '">'); |
|
| 327 | 326 | $file->write('<border diagonalDown="false" diagonalUp="false"><left/><right/><top/><bottom/><diagonal/></border>'); |
| 328 | 327 | foreach ($borders as $border) { |
| 329 | 328 | if (!empty($border)) { //fonts have an empty placeholder in the array to offset the static xml entry above |
| 330 | 329 | $pieces = json_decode($border, true); |
| 331 | 330 | $border_style = !empty($pieces['style']) ? $pieces['style'] : 'hair'; |
| 332 | - $border_color = !empty($pieces['color']) ? '<color rgb="'.strval($pieces['color']).'"/>' : ''; |
|
| 331 | + $border_color = !empty($pieces['color']) ? '<color rgb="' . strval($pieces['color']) . '"/>' : ''; |
|
| 333 | 332 | $file->write('<border diagonalDown="false" diagonalUp="false">'); |
| 334 | 333 | foreach (['left', 'right', 'top', 'bottom'] as $side) { |
| 335 | 334 | $show_side = in_array($side, $pieces['side']) ? true : false; |
@@ -367,7 +366,7 @@ discard block |
||
| 367 | 366 | $file->write('<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="9"/>'); |
| 368 | 367 | $file->write('</cellStyleXfs>'); |
| 369 | 368 | |
| 370 | - $file->write('<cellXfs count="'.(count($styleIndexes)).'">'); |
|
| 369 | + $file->write('<cellXfs count="' . (count($styleIndexes)) . '">'); |
|
| 371 | 370 | foreach ($styleIndexes as $v) { |
| 372 | 371 | $applyAlignment = isset($v['alignment']) ? 'true' : 'false'; |
| 373 | 372 | $wrapText = !empty($v['wrap_text']) ? 'true' : 'false'; |
@@ -378,8 +377,8 @@ discard block |
||
| 378 | 377 | $borderIdx = isset($v['border_idx']) ? intval($v['border_idx']) : 0; |
| 379 | 378 | $fillIdx = isset($v['fill_idx']) ? intval($v['fill_idx']) : 0; |
| 380 | 379 | $fontIdx = isset($v['font_idx']) ? intval($v['font_idx']) : 0; |
| 381 | - $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">'); |
|
| 382 | - $file->write(' <alignment horizontal="'.$horizAlignment.'" vertical="'.$vertAlignment.'" textRotation="0" wrapText="'.$wrapText.'" indent="0" shrinkToFit="false"/>'); |
|
| 380 | + $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">'); |
|
| 381 | + $file->write(' <alignment horizontal="' . $horizAlignment . '" vertical="' . $vertAlignment . '" textRotation="0" wrapText="' . $wrapText . '" indent="0" shrinkToFit="false"/>'); |
|
| 383 | 382 | $file->write(' <protection locked="true" hidden="false"/>'); |
| 384 | 383 | $file->write('</xf>'); |
| 385 | 384 | } |
@@ -423,7 +422,7 @@ discard block |
||
| 423 | 422 | return; |
| 424 | 423 | } |
| 425 | 424 | $style = $colOptions; |
| 426 | - $colWidths = isset($colOptions['widths']) ? (array) $colOptions['widths'] : []; |
|
| 425 | + $colWidths = isset($colOptions['widths']) ? (array)$colOptions['widths'] : []; |
|
| 427 | 426 | $this->createSheet($sheetName, $colOptions); |
| 428 | 427 | $sheet = $this->getSheet($sheetName); |
| 429 | 428 | $sheet->initContent($colWidths, $this->isTabSelected()); |
@@ -432,12 +431,11 @@ discard block |
||
| 432 | 431 | $headerRow = array_keys($headerTypes); |
| 433 | 432 | $writer = $sheet->getFileWriter(); |
| 434 | 433 | $writer->write( |
| 435 | - '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'. 1 .'">' |
|
| 434 | + '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . 1 . '">' |
|
| 436 | 435 | ); |
| 437 | 436 | foreach ($headerRow as $c => $v) { |
| 438 | 437 | $cellStyleIdx = empty($style) ? |
| 439 | - $sheet->columns[$c]['default_cell_style'] : |
|
| 440 | - $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style)); |
|
| 438 | + $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style)); |
|
| 441 | 439 | $sheet->writeCell(0, $c, $v, 'n_string', $cellStyleIdx); |
| 442 | 440 | } |
| 443 | 441 | $writer->write('</row>'); |
@@ -453,7 +451,7 @@ discard block |
||
| 453 | 451 | $numberFormat = Support::numberFormatStandardized($v); |
| 454 | 452 | $cellStyleIdx = $this->addCellStyle($numberFormat, $styleString = null); |
| 455 | 453 | $columns[] = [ |
| 456 | - 'number_format' => $numberFormat, //contains excel format like 'YYYY-MM-DD HH:MM:SS' |
|
| 454 | + 'number_format' => $numberFormat, //contains excel format like 'YYYY-MM-DD HH:MM:SS' |
|
| 457 | 455 | 'number_format_type' => Support::determineNumberFormatType($numberFormat), //contains friendly format like 'datetime' |
| 458 | 456 | 'default_cell_style' => $cellStyleIdx, |
| 459 | 457 | ]; |
@@ -509,7 +507,7 @@ discard block |
||
| 509 | 507 | protected function createSheet(string $sheetName, array $colOptions = []) |
| 510 | 508 | { |
| 511 | 509 | $sheetFilename = $this->tempFilename(); |
| 512 | - $sheetXmlName = 'sheet'.(count($this->sheets) + 1).'.xml'; |
|
| 510 | + $sheetXmlName = 'sheet' . (count($this->sheets) + 1) . '.xml'; |
|
| 513 | 511 | $autoFilter = isset($colOptions['auto_filter']) ? intval($colOptions['auto_filter']) : false; |
| 514 | 512 | $freezeRows = isset($colOptions['freeze_rows']) ? intval($colOptions['freeze_rows']) : false; |
| 515 | 513 | $freezeColumns = isset($colOptions['freeze_columns']) ? intval($colOptions['freeze_columns']) : false; |