Completed
Push — master ( 015c9a...460a97 )
by Once
02:05
created
src/Writer/Builder.php 1 patch
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             $zip->addFile($sheet->filename, 'xl/worksheets/' . $sheet->xmlname);
185 185
         }
186 186
         $zip->addFromString('xl/workbook.xml', XlsxBuilder::buildWorkbookXML($this->sheets));
187
-        $zip->addFile($this->writeStylesXML(), 'xl/styles.xml');  //$zip->addFromString("xl/styles.xml", self::buildStylesXML() );
187
+        $zip->addFile($this->writeStylesXML(), 'xl/styles.xml'); //$zip->addFromString("xl/styles.xml", self::buildStylesXML() );
188 188
         $zip->addFromString('[Content_Types].xml', XlsxBuilder::buildContentTypesXML($this->sheets));
189 189
         $zip->addEmptyDir('xl/_rels/');
190 190
         $zip->addFromString('xl/_rels/workbook.xml.rels', XlsxBuilder::buildWorkbookRelsXML($this->sheets));
@@ -231,8 +231,7 @@  discard block
 block discarded – undo
231 231
         foreach ($row as $v) {
232 232
             $numberFormat     = $sheet->columns[$c]['number_format'];
233 233
             $numberFormatType = $sheet->columns[$c]['number_format_type'];
234
-            $cellStyleIdx     = empty($style) ? $sheet->columns[$c]['default_cell_style'] :
235
-                $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style));
234
+            $cellStyleIdx     = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style));
236 235
             $sheet->writeCell($sheet->rowCount, $c, $v, $numberFormatType, $cellStyleIdx);
237 236
             ++$c;
238 237
         }
@@ -430,8 +429,7 @@  discard block
 block discarded – undo
430 429
             );
431 430
             foreach ($headerRow as $c => $v) {
432 431
                 $cellStyleIdx = empty($style) ?
433
-                    $sheet->columns[$c]['default_cell_style'] :
434
-                    $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style));
432
+                    $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style));
435 433
                 $sheet->writeCell(0, $c, $v, 'n_string', $cellStyleIdx);
436 434
             }
437 435
             $writer->write('</row>');
@@ -445,7 +443,7 @@  discard block
 block discarded – undo
445 443
             $numberFormat = Support::numberFormatStandardized($v);
446 444
             $cellStyleIdx = $this->addCellStyle($numberFormat, $styleString = null);
447 445
             $columns[]    = [
448
-                'number_format'      => $numberFormat,      //contains excel format like 'YYYY-MM-DD HH:MM:SS'
446
+                'number_format'      => $numberFormat, //contains excel format like 'YYYY-MM-DD HH:MM:SS'
449 447
                 'number_format_type' => Support::determineNumberFormatType($numberFormat), //contains friendly format like 'datetime'
450 448
                 'default_cell_style' => $cellStyleIdx,
451 449
             ];
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,39 +63,39 @@  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
                     break;
75 75
                 case 'n_datetime':
76
-                    $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'.
77
-                        Support::convertDateTime($value).'</v></c>');
76
+                    $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' .
77
+                        Support::convertDateTime($value) . '</v></c>');
78 78
                     break;
79 79
                 case 'n_numeric':
80
-                    $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'.
81
-                        Support::xmlSpecialChars($value).'</v></c>'); //int,float,currency
80
+                    $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' .
81
+                        Support::xmlSpecialChars($value) . '</v></c>'); //int,float,currency
82 82
                     break;
83 83
                 case 'n_string':
84
-                    $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'.
85
-                        Support::xmlSpecialChars($value).'</t></is></c>');
84
+                    $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' .
85
+                        Support::xmlSpecialChars($value) . '</t></is></c>');
86 86
                     break;
87 87
                 case 'n_auto':
88 88
                 default: //auto-detect unknown column types
89 89
                     if (!is_string($value) || '0' == $value || ('0' != $value[0] && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", $value)
90 90
                     ) { //int,float,currency
91 91
                         $file->write(
92
-                            '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'.
93
-                            Support::xmlSpecialChars($value).'</v></c>'
92
+                            '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' .
93
+                            Support::xmlSpecialChars($value) . '</v></c>'
94 94
                         );
95 95
                     } else { //implied: ($cell_format=='string')
96 96
                         $file->write(
97
-                            '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'.
98
-                            Support::xmlSpecialChars($value).'</t></is></c>'
97
+                            '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' .
98
+                            Support::xmlSpecialChars($value) . '</t></is></c>'
99 99
                         );
100 100
                     }
101 101
                     break;
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
         $writer      = $this->getFileWriter();
113 113
         $tabSelected = $isTabSelected ? 'true' : 'false';
114 114
         $maxCell     = Support::xlsCell(XlsxWriter::EXCEL_2007_MAX_ROW, XlsxWriter::EXCEL_2007_MAX_COL); //XFE1048577
115
-        $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n");
115
+        $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n");
116 116
         $writer->write(
117 117
             <<<EOF
118 118
 <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>
119 119
 EOF
120 120
         );
121 121
         $this->maxCellTagStart = $this->fileWriter->ftell();
122
-        $writer->write('<dimension ref="A1:'.$maxCell.'"/>');
122
+        $writer->write('<dimension ref="A1:' . $maxCell . '"/>');
123 123
         $this->maxCellTagEnd = $this->fileWriter->ftell();
124 124
         $writer->write('<sheetViews>');
125 125
         $writer->write(
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
         if (!empty($colWidths)) {
142 142
             foreach ($colWidths as $colWidth) {
143 143
                 $writer->write(
144
-                    '<col collapsed="false" hidden="false" max="'.($i + 1).'" min="'.($i + 1).
145
-                    '" style="0" customWidth="true" width="'.floatval($colWidth).'"/>'
144
+                    '<col collapsed="false" hidden="false" max="' . ($i + 1) . '" min="' . ($i + 1) .
145
+                    '" style="0" customWidth="true" width="' . floatval($colWidth) . '"/>'
146 146
                 );
147 147
                 ++$i;
148 148
             }
149 149
         }
150 150
         $writer->write(
151
-            '<col collapsed="false" hidden="false" max="1024" min="'.($i + 1).
152
-            '" style="0" customWidth="false" width="11.5"/>'.'</cols><sheetData>'
151
+            '<col collapsed="false" hidden="false" max="1024" min="' . ($i + 1) .
152
+            '" style="0" customWidth="false" width="11.5"/>' . '</cols><sheetData>'
153 153
         );
154 154
     }
155 155
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         if (!empty($this->merge_cells)) {
161 161
             $this->fileWriter->write('<mergeCells>');
162 162
             foreach ($this->mergeCells as $range) {
163
-                $this->fileWriter->write('<mergeCell ref="'.$range.'"/>');
163
+                $this->fileWriter->write('<mergeCell ref="' . $range . '"/>');
164 164
             }
165 165
             $this->fileWriter->write('</mergeCells>');
166 166
         }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $max_cell = Support::xlsCell($this->rowCount - 1, count($this->columns) - 1);
169 169
 
170 170
         if ($this->autoFilter) {
171
-            $this->fileWriter->write('<autoFilter ref="A1:'.$max_cell.'"/>');
171
+            $this->fileWriter->write('<autoFilter ref="A1:' . $max_cell . '"/>');
172 172
         }
173 173
 
174 174
         $this->fileWriter->write('<printOptions headings="false" gridLines="false" gridLinesSet="true" horizontalCentered="false" verticalCentered="false"/>');
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
         $this->fileWriter->write('</headerFooter>');
181 181
         $this->fileWriter->write('</worksheet>');
182 182
 
183
-        $max_cell_tag   = '<dimension ref="A1:'.$max_cell.'"/>';
183
+        $max_cell_tag   = '<dimension ref="A1:' . $max_cell . '"/>';
184 184
         $padding_length = $this->maxCellTagEnd - $this->maxCellTagStart - strlen($max_cell_tag);
185 185
         $this->fileWriter->fseek($this->maxCellTagStart);
186
-        $this->fileWriter->write($max_cell_tag.str_repeat(' ', $padding_length));
186
+        $this->fileWriter->write($max_cell_tag . str_repeat(' ', $padding_length));
187 187
         $this->fileWriter->close();
188 188
         $this->finalized = true;
189 189
     }
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
     {
193 193
         $writer = $this->getFileWriter();
194 194
         $writer->write(
195
-            '<pane ySplit="'.$this->freezeRows.'" xSplit="'.$this->freezeColumns.
196
-            '" topLeftCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).
197
-            '" activePane="bottomRight" state="frozen"/>'.'<selection activeCell="'.Support::xlsCell($this->freezeRows, 0).
198
-            '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>'.
199
-            '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns).
200
-            '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>'.
201
-            '<selection activeCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).
202
-            '" activeCellId="0" pane="bottomRight" sqref="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).'"/>'
195
+            '<pane ySplit="' . $this->freezeRows . '" xSplit="' . $this->freezeColumns .
196
+            '" topLeftCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) .
197
+            '" activePane="bottomRight" state="frozen"/>' . '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) .
198
+            '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>' .
199
+            '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) .
200
+            '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>' .
201
+            '<selection activeCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) .
202
+            '" activeCellId="0" pane="bottomRight" sqref="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . '"/>'
203 203
         );
204 204
     }
205 205
 
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
     {
208 208
         $writer = $this->getFileWriter();
209 209
         $writer->write(
210
-            '<pane ySplit="'.$this->freezeRows.'" topLeftCell="'.
211
-            Support::xlsCell($this->freezeRows, 0).'" activePane="bottomLeft" state="frozen"/>'.
212
-            '<selection activeCell="'.Support::xlsCell($this->freezeRows, 0).
213
-            '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>'
210
+            '<pane ySplit="' . $this->freezeRows . '" topLeftCell="' .
211
+            Support::xlsCell($this->freezeRows, 0) . '" activePane="bottomLeft" state="frozen"/>' .
212
+            '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) .
213
+            '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>'
214 214
         );
215 215
     }
216 216
 
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
     {
219 219
         $writer = $this->getFileWriter();
220 220
         $writer->write(
221
-            '<pane xSplit="'.$this->freezeColumns.'" topLeftCell="'.
222
-            Support::xlsCell(0, $this->freezeColumns).'" activePane="topRight" state="frozen"/>'.
223
-            '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns).
224
-            '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>'
221
+            '<pane xSplit="' . $this->freezeColumns . '" topLeftCell="' .
222
+            Support::xlsCell(0, $this->freezeColumns) . '" activePane="topRight" state="frozen"/>' .
223
+            '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) .
224
+            '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>'
225 225
         );
226 226
     }
227 227
 
Please login to merge, or discard this patch.