Completed
Pull Request — master (#1)
by Once
03:32 queued 01:30
created
src/Writer/XlsxBuilder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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"/>';
Please login to merge, or discard this patch.
src/Writer/Builder.php 1 patch
Spacing   +32 added lines, -34 removed lines patch added patch discarded remove patch
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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));
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
         $sheet = $this->getSheet();
215 215
         if (count($sheet->columns) < count($row)) {
216 216
             $defaultColumnTypes = $this->initColumnsTypes(array_fill($from = 0, count($row), 'GENERAL')); //will map to n_auto
217
-            $sheet->columns = array_merge((array) $sheet->columns, $defaultColumnTypes);
217
+            $sheet->columns = array_merge((array)$sheet->columns, $defaultColumnTypes);
218 218
         }
219 219
 
220 220
         if (!empty($rowOptions)) {
221 221
             $ht = isset($rowOptions['height']) ? floatval($rowOptions['height']) : 12.1;
222 222
             $customHt = isset($rowOptions['height']) ? true : false;
223
-            $hidden = isset($rowOptions['hidden']) ? (bool) ($rowOptions['hidden']) : false;
224
-            $collapsed = isset($rowOptions['collapsed']) ? (bool) ($rowOptions['collapsed']) : false;
223
+            $hidden = isset($rowOptions['hidden']) ? (bool)($rowOptions['hidden']) : false;
224
+            $collapsed = isset($rowOptions['collapsed']) ? (bool)($rowOptions['collapsed']) : false;
225 225
             $sheet->fileWriter->write(
226
-                '<row collapsed="'.($collapsed).'" customFormat="false" customHeight="'.($customHt).
227
-                '" hidden="'.($hidden).'" ht="'.($ht).'" outlineLevel="0" r="'.($sheet->rowCount + 1).'">'
226
+                '<row collapsed="' . ($collapsed) . '" customFormat="false" customHeight="' . ($customHt) .
227
+                '" hidden="' . ($hidden) . '" ht="' . ($ht) . '" outlineLevel="0" r="' . ($sheet->rowCount + 1) . '">'
228 228
             );
229 229
         } else {
230 230
             $sheet->fileWriter->write(
231
-                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'.
232
-                ($sheet->rowCount + 1).'">'
231
+                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' .
232
+                ($sheet->rowCount + 1) . '">'
233 233
             );
234 234
         }
235 235
 
@@ -238,8 +238,7 @@  discard block
 block discarded – undo
238 238
         foreach ($row as $v) {
239 239
             $numberFormat = $sheet->columns[$c]['number_format'];
240 240
             $numberFormatType = $sheet->columns[$c]['number_format_type'];
241
-            $cellStyleIdx = empty($style) ? $sheet->columns[$c]['default_cell_style'] :
242
-                $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style));
241
+            $cellStyleIdx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style));
243 242
             $sheet->writeCell($sheet->rowCount, $c, $v, $numberFormatType, $cellStyleIdx);
244 243
             ++$c;
245 244
         }
@@ -275,14 +274,14 @@  discard block
 block discarded – undo
275 274
 
276 275
         $temporaryFilename = $this->tempFilename();
277 276
         $file = new XlsxWriterBuffer($temporaryFilename);
278
-        $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n");
277
+        $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n");
279 278
         $file->write('<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">');
280
-        $file->write('<numFmts count="'.count($this->numberFormats).'">');
279
+        $file->write('<numFmts count="' . count($this->numberFormats) . '">');
281 280
         foreach ($this->numberFormats as $i => $v) {
282
-            $file->write('<numFmt numFmtId="'.(164 + $i).'" formatCode="'.Support::xmlSpecialChars($v).'" />');
281
+            $file->write('<numFmt numFmtId="' . (164 + $i) . '" formatCode="' . Support::xmlSpecialChars($v) . '" />');
283 282
         }
284 283
         $file->write('</numFmts>');
285
-        $file->write('<fonts count="'.(count($fonts)).'">');
284
+        $file->write('<fonts count="' . (count($fonts)) . '">');
286 285
         $file->write('<font><name val="Arial"/><charset val="1"/><family val="2"/><sz val="10"/></font>');
287 286
         $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
288 287
         $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
@@ -292,10 +291,10 @@  discard block
 block discarded – undo
292 291
             if (!empty($font)) { //fonts have 4 empty placeholders in array to offset the 4 static xml entries above
293 292
                 $f = json_decode($font, true);
294 293
                 $file->write('<font>');
295
-                $file->write('<name val="'.htmlspecialchars($f['name']).'"/><charset val="1"/><family val="'.intval($f['family']).'"/>');
296
-                $file->write('<sz val="'.intval($f['size']).'"/>');
294
+                $file->write('<name val="' . htmlspecialchars($f['name']) . '"/><charset val="1"/><family val="' . intval($f['family']) . '"/>');
295
+                $file->write('<sz val="' . intval($f['size']) . '"/>');
297 296
                 if (!empty($f['color'])) {
298
-                    $file->write('<color rgb="'.strval($f['color']).'"/>');
297
+                    $file->write('<color rgb="' . strval($f['color']) . '"/>');
299 298
                 }
300 299
                 if (!empty($f['bold'])) {
301 300
                     $file->write('<b val="true"/>');
@@ -314,23 +313,23 @@  discard block
 block discarded – undo
314 313
         }
315 314
         $file->write('</fonts>');
316 315
 
317
-        $file->write('<fills count="'.(count($fills)).'">');
316
+        $file->write('<fills count="' . (count($fills)) . '">');
318 317
         $file->write('<fill><patternFill patternType="none"/></fill>');
319 318
         $file->write('<fill><patternFill patternType="gray125"/></fill>');
320 319
         foreach ($fills as $fill) {
321 320
             if (!empty($fill)) { //fills have 2 empty placeholders in array to offset the 2 static xml entries above
322
-                $file->write('<fill><patternFill patternType="solid"><fgColor rgb="'.strval($fill).'"/><bgColor indexed="64"/></patternFill></fill>');
321
+                $file->write('<fill><patternFill patternType="solid"><fgColor rgb="' . strval($fill) . '"/><bgColor indexed="64"/></patternFill></fill>');
323 322
             }
324 323
         }
325 324
         $file->write('</fills>');
326 325
 
327
-        $file->write('<borders count="'.(count($borders)).'">');
326
+        $file->write('<borders count="' . (count($borders)) . '">');
328 327
         $file->write('<border diagonalDown="false" diagonalUp="false"><left/><right/><top/><bottom/><diagonal/></border>');
329 328
         foreach ($borders as $border) {
330 329
             if (!empty($border)) { //fonts have an empty placeholder in the array to offset the static xml entry above
331 330
                 $pieces = json_decode($border, true);
332 331
                 $border_style = !empty($pieces['style']) ? $pieces['style'] : 'hair';
333
-                $border_color = !empty($pieces['color']) ? '<color rgb="'.strval($pieces['color']).'"/>' : '';
332
+                $border_color = !empty($pieces['color']) ? '<color rgb="' . strval($pieces['color']) . '"/>' : '';
334 333
                 $file->write('<border diagonalDown="false" diagonalUp="false">');
335 334
                 foreach (['left', 'right', 'top', 'bottom'] as $side) {
336 335
                     $show_side = in_array($side, $pieces['side']) ? true : false;
@@ -368,7 +367,7 @@  discard block
 block discarded – undo
368 367
         $file->write('<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="9"/>');
369 368
         $file->write('</cellStyleXfs>');
370 369
 
371
-        $file->write('<cellXfs count="'.(count($styleIndexes)).'">');
370
+        $file->write('<cellXfs count="' . (count($styleIndexes)) . '">');
372 371
         foreach ($styleIndexes as $v) {
373 372
             $applyAlignment = isset($v['alignment']) ? 'true' : 'false';
374 373
             $wrapText = !empty($v['wrap_text']) ? 'true' : 'false';
@@ -379,8 +378,8 @@  discard block
 block discarded – undo
379 378
             $borderIdx = isset($v['border_idx']) ? intval($v['border_idx']) : 0;
380 379
             $fillIdx = isset($v['fill_idx']) ? intval($v['fill_idx']) : 0;
381 380
             $fontIdx = isset($v['font_idx']) ? intval($v['font_idx']) : 0;
382
-            $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">');
383
-            $file->write('	<alignment horizontal="'.$horizAlignment.'" vertical="'.$vertAlignment.'" textRotation="0" wrapText="'.$wrapText.'" indent="0" shrinkToFit="false"/>');
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"/>');
384 383
             $file->write('	<protection locked="true" hidden="false"/>');
385 384
             $file->write('</xf>');
386 385
         }
@@ -424,7 +423,7 @@  discard block
 block discarded – undo
424 423
             return;
425 424
         }
426 425
         $style = $colOptions;
427
-        $colWidths = isset($colOptions['widths']) ? (array) $colOptions['widths'] : [];
426
+        $colWidths = isset($colOptions['widths']) ? (array)$colOptions['widths'] : [];
428 427
         $this->createSheet($sheetName, $colOptions);
429 428
         $sheet = $this->getSheet();
430 429
         $sheet->initContent($colWidths, $this->isTabSelected());
@@ -433,12 +432,11 @@  discard block
 block discarded – undo
433 432
             $headerRow = array_keys($headerTypes);
434 433
             $writer = $sheet->getFileWriter();
435 434
             $writer->write(
436
-                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'. 1 .'">'
435
+                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . 1 . '">'
437 436
             );
438 437
             foreach ($headerRow as $c => $v) {
439 438
                 $cellStyleIdx = empty($style) ?
440
-                    $sheet->columns[$c]['default_cell_style'] :
441
-                    $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style));
439
+                    $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style));
442 440
                 $sheet->writeCell(0, $c, $v, 'n_string', $cellStyleIdx);
443 441
             }
444 442
             $writer->write('</row>');
@@ -452,7 +450,7 @@  discard block
 block discarded – undo
452 450
             $numberFormat = Support::numberFormatStandardized($v);
453 451
             $cellStyleIdx = $this->addCellStyle($numberFormat, $styleString = null);
454 452
             $columns[] = [
455
-                'number_format' => $numberFormat,      //contains excel format like 'YYYY-MM-DD HH:MM:SS'
453
+                'number_format' => $numberFormat, //contains excel format like 'YYYY-MM-DD HH:MM:SS'
456 454
                 'number_format_type' => Support::determineNumberFormatType($numberFormat), //contains friendly format like 'datetime'
457 455
                 'default_cell_style' => $cellStyleIdx,
458 456
             ];
@@ -508,7 +506,7 @@  discard block
 block discarded – undo
508 506
     protected function createSheet(string $sheetName, array $colOptions = [])
509 507
     {
510 508
         $sheetFilename = $this->tempFilename();
511
-        $sheetXmlName = 'sheet'.(count($this->sheets) + 1).'.xml';
509
+        $sheetXmlName = 'sheet' . (count($this->sheets) + 1) . '.xml';
512 510
         $autoFilter = isset($colOptions['auto_filter']) ? intval($colOptions['auto_filter']) : false;
513 511
         $freezeRows = isset($colOptions['freeze_rows']) ? intval($colOptions['freeze_rows']) : false;
514 512
         $freezeColumns = isset($colOptions['freeze_columns']) ? intval($colOptions['freeze_columns']) : false;
Please login to merge, or discard this patch.
src/Writer/Style.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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));
Please login to merge, or discard this patch.
src/Writer/Sheet.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -63,28 +63,28 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
116 116
         $writer = $this->getFileWriter();
117 117
         $tabSelected = $isTabSelected ? 'true' : 'false';
118 118
         $maxCell = Support::xlsCell(XlsxWriter::EXCEL_2007_MAX_ROW, XlsxWriter::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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Support.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.