@@ -99,9 +99,9 @@ |
||
99 | 99 | { |
100 | 100 | return [ |
101 | 101 | 'SKU' => 'string', |
102 | - '尺码' => 'string', // sku |
|
103 | - '净重' => 'string', // sku |
|
104 | - '单价' => 'prices', // sku |
|
102 | + '尺码' => 'string', // sku |
|
103 | + '净重' => 'string', // sku |
|
104 | + '单价' => 'prices', // sku |
|
105 | 105 | ]; |
106 | 106 | } |
107 | 107 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $author = Support::xmlSpecialChars($author); |
47 | 47 | $keywords = Support::xmlSpecialChars(implode(',', $keywords)); |
48 | 48 | if ($keywords) { |
49 | - $keywords = '<cp:keywords>'.$keywords.'</cp:keywords>'; |
|
49 | + $keywords = '<cp:keywords>' . $keywords . '</cp:keywords>'; |
|
50 | 50 | } |
51 | 51 | $description = Support::xmlSpecialChars($description); |
52 | 52 | $date = date("Y-m-d\TH:i:s.00\Z"); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public static function buildRelationshipsXML() |
68 | 68 | { |
69 | 69 | $relsXml = ''; |
70 | - $relsXml .= '<?xml version="1.0" encoding="UTF-8"?>'."\n"; |
|
70 | + $relsXml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
|
71 | 71 | $relsXml .= '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'; |
72 | 72 | $relsXml .= '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'; |
73 | 73 | $relsXml .= '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>'; |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | EOF; |
93 | 93 | foreach ($sheets as $sheetName => $sheet) { |
94 | 94 | $sheetname = Support::sanitizeSheetname($sheet->sheetname); |
95 | - $workbookXml .= '<sheet name="'.Support::xmlSpecialChars($sheetname). |
|
96 | - '" sheetId="'.($i + 1).'" state="visible" r:id="rId'.($i + 2).'"/>'; |
|
95 | + $workbookXml .= '<sheet name="' . Support::xmlSpecialChars($sheetname) . |
|
96 | + '" sheetId="' . ($i + 1) . '" state="visible" r:id="rId' . ($i + 2) . '"/>'; |
|
97 | 97 | ++$i; |
98 | 98 | } |
99 | 99 | $workbookXml .= '</sheets><definedNames>'; |
100 | 100 | foreach ($sheets as $sheetName => $sheet) { |
101 | 101 | if ($sheet->autoFilter) { |
102 | 102 | $sheetname = Support::sanitizeSheetname($sheet->sheetname); |
103 | - $workbookXml .= '<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\''. |
|
104 | - Support::xmlSpecialChars($sheetname).'\'!$A$1:'. |
|
105 | - Support::xlsCell($sheet->rowCount - 1, count($sheet->columns) - 1, true).'</definedName>'; |
|
103 | + $workbookXml .= '<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\'' . |
|
104 | + Support::xmlSpecialChars($sheetname) . '\'!$A$1:' . |
|
105 | + Support::xlsCell($sheet->rowCount - 1, count($sheet->columns) - 1, true) . '</definedName>'; |
|
106 | 106 | ++$i; |
107 | 107 | } |
108 | 108 | } |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/> |
125 | 125 | EOF; |
126 | 126 | foreach ($sheets as $sheetName => $sheet) { |
127 | - $wkbkrelsXml .= '<Relationship Id="rId'.($i + 2). |
|
128 | - '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/'. |
|
129 | - ($sheet->xmlname).'"/>'; |
|
127 | + $wkbkrelsXml .= '<Relationship Id="rId' . ($i + 2) . |
|
128 | + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/' . |
|
129 | + ($sheet->xmlname) . '"/>'; |
|
130 | 130 | ++$i; |
131 | 131 | } |
132 | - $wkbkrelsXml .= "\n".'</Relationships>'; |
|
132 | + $wkbkrelsXml .= "\n" . '</Relationships>'; |
|
133 | 133 | |
134 | 134 | return $wkbkrelsXml; |
135 | 135 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | public static function buildContentTypesXML(array $sheets) |
143 | 143 | { |
144 | 144 | $contentTypesXml = ''; |
145 | - $contentTypesXml .= '<?xml version="1.0" encoding="UTF-8"?>'."\n"; |
|
145 | + $contentTypesXml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
|
146 | 146 | $contentTypesXml .= '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'; |
147 | 147 | $contentTypesXml .= '<Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'; |
148 | 148 | $contentTypesXml .= '<Override PartName="/xl/_rels/workbook.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'; |
149 | 149 | foreach ($sheets as $sheetName => $sheet) { |
150 | - $contentTypesXml .= '<Override PartName="/xl/worksheets/'.($sheet->xmlname).'" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>'; |
|
150 | + $contentTypesXml .= '<Override PartName="/xl/worksheets/' . ($sheet->xmlname) . '" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>'; |
|
151 | 151 | } |
152 | 152 | $contentTypesXml .= '<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>'; |
153 | 153 | $contentTypesXml .= '<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | protected function addCellStyle($numberFormat, $cellStyleString) |
58 | 58 | { |
59 | 59 | $numberFormatIdx = Support::add2listGetIndex($this->numberFormats, $numberFormat); |
60 | - $lookupString = $numberFormatIdx.';'.$cellStyleString; |
|
60 | + $lookupString = $numberFormatIdx . ';' . $cellStyleString; |
|
61 | 61 | |
62 | 62 | return Support::add2listGetIndex($this->cellStyles, $lookupString); |
63 | 63 | } |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | } |
82 | 82 | if (isset($style['border-color']) && is_string($style['border-color']) && '#' == $style['border-color'][0]) { |
83 | 83 | $v = substr($style['border-color'], 1, 6); |
84 | - $v = 3 == strlen($v) ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00 |
|
85 | - $border_value['color'] = 'FF'.strtoupper($v); |
|
84 | + $v = 3 == strlen($v) ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v; // expand cf0 => ccff00 |
|
85 | + $border_value['color'] = 'FF' . strtoupper($v); |
|
86 | 86 | } |
87 | 87 | $styleIndexes[$i]['border_idx'] = Support::add2listGetIndex($borders, json_encode($borderValue)); |
88 | 88 | } |
89 | 89 | if (isset($style['fill']) && is_string($style['fill']) && '#' == $style['fill'][0]) { |
90 | 90 | $v = substr($style['fill'], 1, 6); |
91 | - $v = 3 == strlen($v) ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00 |
|
92 | - $styleIndexes[$i]['fill_idx'] = Support::add2listGetIndex($fills, 'FF'.strtoupper($v)); |
|
91 | + $v = 3 == strlen($v) ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v; // expand cf0 => ccff00 |
|
92 | + $styleIndexes[$i]['fill_idx'] = Support::add2listGetIndex($fills, 'FF' . strtoupper($v)); |
|
93 | 93 | } |
94 | 94 | if (isset($style['halign']) && in_array($style['halign'], $this->horizontalAllowed)) { |
95 | 95 | $styleIndexes[$i]['alignment'] = true; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | if (isset($style['wrap_text'])) { |
103 | 103 | $styleIndexes[$i]['alignment'] = true; |
104 | - $styleIndexes[$i]['wrap_text'] = (bool) $style['wrap_text']; |
|
104 | + $styleIndexes[$i]['wrap_text'] = (bool)$style['wrap_text']; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $font = $this->defaultFont; |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | } |
137 | 137 | if (isset($style['color']) && is_string($style['color']) && '#' == $style['color'][0]) { |
138 | 138 | $v = substr($style['color'], 1, 6); |
139 | - $v = 3 == strlen($v) ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00 |
|
140 | - $font['color'] = 'FF'.strtoupper($v); |
|
139 | + $v = 3 == strlen($v) ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v; // expand cf0 => ccff00 |
|
140 | + $font['color'] = 'FF' . strtoupper($v); |
|
141 | 141 | } |
142 | 142 | if ($font != $this->defaultFont) { |
143 | 143 | $styleIndexes[$i]['font_idx'] = Support::add2listGetIndex($fonts, json_encode($font)); |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | { |
23 | 23 | $n = $columnNumber; |
24 | 24 | for ($r = ''; $n >= 0; $n = intval($n / 26) - 1) { |
25 | - $r = chr($n % 26 + 0x41).$r; |
|
25 | + $r = chr($n % 26 + 0x41) . $r; |
|
26 | 26 | } |
27 | 27 | if ($absolute) { |
28 | - return '$'.$r.'$'.($rowNumber + 1); |
|
28 | + return '$' . $r . '$' . ($rowNumber + 1); |
|
29 | 29 | } |
30 | 30 | |
31 | - return $r.($rowNumber + 1); |
|
31 | + return $r . ($rowNumber + 1); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $ignoreUntil = ''; |
91 | 91 | } |
92 | 92 | if ('' == $ignoreUntil && (' ' == $c || '-' == $c || '(' == $c || ')' == $c) && (0 == $i || '_' != $numFormat[$i - 1])) { |
93 | - $escaped .= '\\'.$c; |
|
93 | + $escaped .= '\\' . $c; |
|
94 | 94 | } else { |
95 | 95 | $escaped .= $c; |
96 | 96 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public static function convertDateTime($dateInput) |
166 | 166 | { |
167 | - $seconds = 0; // Time expressed as fraction of 24h hours in seconds |
|
167 | + $seconds = 0; // Time expressed as fraction of 24h hours in seconds |
|
168 | 168 | $year = $month = $day = 0; |
169 | 169 | |
170 | 170 | $date_time = $dateInput; |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | return 0; |
211 | 211 | } |
212 | 212 | // Accumulate the number of days since the epoch. |
213 | - $days = $day; // Add days for current month |
|
214 | - $days += array_sum(array_slice($mdays, 0, $month - 1)); // Add days for past months |
|
215 | - $days += $range * 365; // Add days for past years |
|
216 | - $days += intval(($range) / 4); // Add leapdays |
|
213 | + $days = $day; // Add days for current month |
|
214 | + $days += array_sum(array_slice($mdays, 0, $month - 1)); // Add days for past months |
|
215 | + $days += $range * 365; // Add days for past years |
|
216 | + $days += intval(($range) / 4); // Add leapdays |
|
217 | 217 | $days -= intval(($range + $offset) / 100); // Subtract 100 year leapdays |
218 | - $days += intval(($range + $offset + $norm) / 400); // Add 400 year leapdays |
|
219 | - $days -= $leap; // Already counted above |
|
218 | + $days += intval(($range + $offset + $norm) / 400); // Add 400 year leapdays |
|
219 | + $days -= $leap; // Already counted above |
|
220 | 220 | // Adjust for Excel erroneously treating 1900 as a leap year. |
221 | 221 | if ($days > 59) { |
222 | 222 | ++$days; |
@@ -233,6 +233,6 @@ discard block |
||
233 | 233 | $sheetname = mb_substr($sheetname, 0, 31); |
234 | 234 | $sheetname = trim(trim(trim($sheetname), "'")); //trim before and after trimming single quotes |
235 | 235 | |
236 | - return !empty($sheetname) ? $sheetname : 'Sheet'.((rand() % 900) + 100); |
|
236 | + return !empty($sheetname) ? $sheetname : 'Sheet' . ((rand() % 900) + 100); |
|
237 | 237 | } |
238 | 238 | } |
@@ -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 | } |
@@ -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>'); |
@@ -455,7 +453,7 @@ discard block |
||
455 | 453 | $numberFormat = Support::numberFormatStandardized($numFormat); |
456 | 454 | $cellStyleIdx = $this->addCellStyle($numberFormat, $styleString = null); |
457 | 455 | $columns[] = [ |
458 | - 'number_format' => $numberFormat, //contains excel format like 'YYYY-MM-DD HH:MM:SS' |
|
456 | + 'number_format' => $numberFormat, //contains excel format like 'YYYY-MM-DD HH:MM:SS' |
|
459 | 457 | 'number_format_type' => Support::determineNumberFormatType($numberFormat, 'function' === $v[0]), //contains friendly format like 'datetime' |
460 | 458 | 'default_cell_style' => $cellStyleIdx, |
461 | 459 | ]; |
@@ -511,7 +509,7 @@ discard block |
||
511 | 509 | protected function createSheet(string $sheetName, array $colOptions = []) |
512 | 510 | { |
513 | 511 | $sheetFilename = $this->tempFilename(); |
514 | - $sheetXmlName = 'sheet'.(count($this->sheets) + 1).'.xml'; |
|
512 | + $sheetXmlName = 'sheet' . (count($this->sheets) + 1) . '.xml'; |
|
515 | 513 | $autoFilter = isset($colOptions['auto_filter']) ? intval($colOptions['auto_filter']) : false; |
516 | 514 | $freezeRows = isset($colOptions['freeze_rows']) ? intval($colOptions['freeze_rows']) : false; |
517 | 515 | $freezeColumns = isset($colOptions['freeze_columns']) ? intval($colOptions['freeze_columns']) : false; |
@@ -64,39 +64,39 @@ discard block |
||
64 | 64 | $file = $this->getFileWriter(); |
65 | 65 | |
66 | 66 | if (!is_scalar($value) || '' === $value) { //objects, array, empty |
67 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'"/>'); |
|
67 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '"/>'); |
|
68 | 68 | } elseif (is_string($value) && '=' == $value[0]) { |
69 | 69 | // Support Formula |
70 | 70 | if ('n_function' === $numFormatType) { |
71 | - var_dump('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="s"><f>'. |
|
71 | + var_dump('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="s"><f>' . |
|
72 | 72 | str_replace('{n}', $rowNumber + 1, substr($value, 1)) |
73 | 73 | .'</f></c>'); |
74 | 74 | |
75 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="s"><f>'. |
|
75 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="s"><f>' . |
|
76 | 76 | str_replace('{n}', $rowNumber + 1, substr($value, 1)) |
77 | 77 | .'</f></c>'); |
78 | 78 | } else { |
79 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="s"><f>'.Support::xmlSpecialChars($value).'</f></c>'); |
|
79 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="s"><f>' . Support::xmlSpecialChars($value) . '</f></c>'); |
|
80 | 80 | } |
81 | 81 | } else { |
82 | 82 | switch ($numFormatType) { |
83 | 83 | case 'n_date': |
84 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
85 | - intval(Support::convertDateTime($value)).'</v></c>'); |
|
84 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
85 | + intval(Support::convertDateTime($value)) . '</v></c>'); |
|
86 | 86 | |
87 | 87 | break; |
88 | 88 | case 'n_datetime': |
89 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
90 | - Support::convertDateTime($value).'</v></c>'); |
|
89 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
90 | + Support::convertDateTime($value) . '</v></c>'); |
|
91 | 91 | |
92 | 92 | break; |
93 | 93 | case 'n_numeric': |
94 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
95 | - Support::xmlSpecialChars($value).'</v></c>'); //int,float,currency |
|
94 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
95 | + Support::xmlSpecialChars($value) . '</v></c>'); //int,float,currency |
|
96 | 96 | break; |
97 | 97 | case 'n_string': |
98 | - $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'. |
|
99 | - Support::xmlSpecialChars($value).'</t></is></c>'); |
|
98 | + $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' . |
|
99 | + Support::xmlSpecialChars($value) . '</t></is></c>'); |
|
100 | 100 | |
101 | 101 | break; |
102 | 102 | case 'n_auto': |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | if (!is_string($value) || '0' == $value || ('0' != $value[0] && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", $value) |
105 | 105 | ) { //int,float,currency |
106 | 106 | $file->write( |
107 | - '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'. |
|
108 | - Support::xmlSpecialChars($value).'</v></c>' |
|
107 | + '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' . |
|
108 | + Support::xmlSpecialChars($value) . '</v></c>' |
|
109 | 109 | ); |
110 | 110 | } else { //implied: ($cell_format=='string') |
111 | 111 | $file->write( |
112 | - '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'. |
|
113 | - Support::xmlSpecialChars($value).'</t></is></c>' |
|
112 | + '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' . |
|
113 | + Support::xmlSpecialChars($value) . '</t></is></c>' |
|
114 | 114 | ); |
115 | 115 | } |
116 | 116 | |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | $writer = $this->getFileWriter(); |
129 | 129 | $tabSelected = $isTabSelected ? 'true' : 'false'; |
130 | 130 | $maxCell = Support::xlsCell(Builder::EXCEL_2007_MAX_ROW, Builder::EXCEL_2007_MAX_COL); //XFE1048577 |
131 | - $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"); |
|
131 | + $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"); |
|
132 | 132 | $writer->write( |
133 | 133 | <<<'EOF' |
134 | 134 | <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> |
135 | 135 | EOF |
136 | 136 | ); |
137 | 137 | $this->maxCellTagStart = $this->fileWriter->ftell(); |
138 | - $writer->write('<dimension ref="A1:'.$maxCell.'"/>'); |
|
138 | + $writer->write('<dimension ref="A1:' . $maxCell . '"/>'); |
|
139 | 139 | $this->maxCellTagEnd = $this->fileWriter->ftell(); |
140 | 140 | $writer->write('<sheetViews>'); |
141 | 141 | $writer->write( |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | if (!empty($colWidths)) { |
158 | 158 | foreach ($colWidths as $colWidth) { |
159 | 159 | $writer->write( |
160 | - '<col collapsed="false" hidden="false" max="'.($i + 1).'" min="'.($i + 1). |
|
161 | - '" style="0" customWidth="true" width="'.floatval($colWidth).'"/>' |
|
160 | + '<col collapsed="false" hidden="false" max="' . ($i + 1) . '" min="' . ($i + 1) . |
|
161 | + '" style="0" customWidth="true" width="' . floatval($colWidth) . '"/>' |
|
162 | 162 | ); |
163 | 163 | ++$i; |
164 | 164 | } |
165 | 165 | } |
166 | 166 | $writer->write( |
167 | - '<col collapsed="false" hidden="false" max="1024" min="'.($i + 1). |
|
168 | - '" style="0" customWidth="false" width="11.5"/>'.'</cols><sheetData>' |
|
167 | + '<col collapsed="false" hidden="false" max="1024" min="' . ($i + 1) . |
|
168 | + '" style="0" customWidth="false" width="11.5"/>' . '</cols><sheetData>' |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if (!empty($this->mergeCells)) { |
177 | 177 | $this->fileWriter->write('<mergeCells>'); |
178 | 178 | foreach ($this->mergeCells as $range) { |
179 | - $this->fileWriter->write('<mergeCell ref="'.$range.'"/>'); |
|
179 | + $this->fileWriter->write('<mergeCell ref="' . $range . '"/>'); |
|
180 | 180 | } |
181 | 181 | $this->fileWriter->write('</mergeCells>'); |
182 | 182 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $maxCell = Support::xlsCell($this->rowCount - 1, count($this->columns) - 1); |
185 | 185 | |
186 | 186 | if ($this->autoFilter) { |
187 | - $this->fileWriter->write('<autoFilter ref="A1:'.$maxCell.'"/>'); |
|
187 | + $this->fileWriter->write('<autoFilter ref="A1:' . $maxCell . '"/>'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $this->fileWriter->write('<printOptions headings="false" gridLines="false" gridLinesSet="true" horizontalCentered="false" verticalCentered="false"/>'); |
@@ -196,10 +196,10 @@ discard block |
||
196 | 196 | $this->fileWriter->write('</headerFooter>'); |
197 | 197 | $this->fileWriter->write('</worksheet>'); |
198 | 198 | |
199 | - $maxCellTag = '<dimension ref="A1:'.$maxCell.'"/>'; |
|
199 | + $maxCellTag = '<dimension ref="A1:' . $maxCell . '"/>'; |
|
200 | 200 | $paddingLength = $this->maxCellTagEnd - $this->maxCellTagStart - strlen($maxCellTag); |
201 | 201 | $this->fileWriter->fseek($this->maxCellTagStart); |
202 | - $this->fileWriter->write($maxCellTag.str_repeat(' ', $paddingLength)); |
|
202 | + $this->fileWriter->write($maxCellTag . str_repeat(' ', $paddingLength)); |
|
203 | 203 | $this->fileWriter->close(); |
204 | 204 | $this->finalized = true; |
205 | 205 | } |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | { |
209 | 209 | $writer = $this->getFileWriter(); |
210 | 210 | $writer->write( |
211 | - '<pane ySplit="'.$this->freezeRows.'" xSplit="'.$this->freezeColumns. |
|
212 | - '" topLeftCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns). |
|
213 | - '" activePane="bottomRight" state="frozen"/>'.'<selection activeCell="'.Support::xlsCell($this->freezeRows, 0). |
|
214 | - '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>'. |
|
215 | - '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns). |
|
216 | - '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>'. |
|
217 | - '<selection activeCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns). |
|
218 | - '" activeCellId="0" pane="bottomRight" sqref="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).'"/>' |
|
211 | + '<pane ySplit="' . $this->freezeRows . '" xSplit="' . $this->freezeColumns . |
|
212 | + '" topLeftCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . |
|
213 | + '" activePane="bottomRight" state="frozen"/>' . '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) . |
|
214 | + '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>' . |
|
215 | + '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) . |
|
216 | + '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>' . |
|
217 | + '<selection activeCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . |
|
218 | + '" activeCellId="0" pane="bottomRight" sqref="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . '"/>' |
|
219 | 219 | ); |
220 | 220 | } |
221 | 221 | |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | { |
224 | 224 | $writer = $this->getFileWriter(); |
225 | 225 | $writer->write( |
226 | - '<pane ySplit="'.$this->freezeRows.'" topLeftCell="'. |
|
227 | - Support::xlsCell($this->freezeRows, 0).'" activePane="bottomLeft" state="frozen"/>'. |
|
228 | - '<selection activeCell="'.Support::xlsCell($this->freezeRows, 0). |
|
229 | - '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>' |
|
226 | + '<pane ySplit="' . $this->freezeRows . '" topLeftCell="' . |
|
227 | + Support::xlsCell($this->freezeRows, 0) . '" activePane="bottomLeft" state="frozen"/>' . |
|
228 | + '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) . |
|
229 | + '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>' |
|
230 | 230 | ); |
231 | 231 | } |
232 | 232 | |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | { |
235 | 235 | $writer = $this->getFileWriter(); |
236 | 236 | $writer->write( |
237 | - '<pane xSplit="'.$this->freezeColumns.'" topLeftCell="'. |
|
238 | - Support::xlsCell(0, $this->freezeColumns).'" activePane="topRight" state="frozen"/>'. |
|
239 | - '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns). |
|
240 | - '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>' |
|
237 | + '<pane xSplit="' . $this->freezeColumns . '" topLeftCell="' . |
|
238 | + Support::xlsCell(0, $this->freezeColumns) . '" activePane="topRight" state="frozen"/>' . |
|
239 | + '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) . |
|
240 | + '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>' |
|
241 | 241 | ); |
242 | 242 | } |
243 | 243 |