Completed
Push — develop ( 5e03e2...c8a8fd )
by Adrien
28:49
created

Gnumeric::listWorksheetNames()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 21
Code Lines 13

Duplication

Lines 7
Ratio 33.33 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 13
nc 4
nop 1
dl 7
loc 21
ccs 0
cts 13
cp 0
crap 30
rs 8.7624
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Reader;
4
5
use DateTimeZone;
6
use PhpOffice\PhpSpreadsheet\Shared\File;
7
use PhpOffice\PhpSpreadsheet\Spreadsheet;
8
9
/**
10
 * Copyright (c) 2006 - 2016 PhpSpreadsheet
11
 *
12
 * This library is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU Lesser General Public
14
 * License as published by the Free Software Foundation; either
15
 * version 2.1 of the License, or (at your option) any later version.
16
 *
17
 * This library is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
 * Lesser General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Lesser General Public
23
 * License along with this library; if not, write to the Free Software
24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
25
 *
26
 * @category   PhpSpreadsheet
27
 * @copyright  Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
28
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
29
 */
30
class Gnumeric extends BaseReader implements IReader
31
{
32
    /**
33
     * Formats
34
     *
35
     * @var array
36
     */
37
    private $styles = [];
0 ignored issues
show
Unused Code introduced by
The property $styles is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
38
39
    /**
40
     * Shared Expressions
41
     *
42
     * @var array
43
     */
44
    private $expressions = [];
45
46
    private $referenceHelper = null;
47
48
    /**
49
     * Create a new Gnumeric
50
     */
51 2
    public function __construct()
52
    {
53 2
        $this->readFilter = new DefaultReadFilter();
54 2
        $this->referenceHelper = \PhpOffice\PhpSpreadsheet\ReferenceHelper::getInstance();
55 2
    }
56
57
    /**
58
     * Can the current IReader read the file?
59
     *
60
     * @param     string         $pFilename
61
     * @throws Exception
62
     * @return     bool
63
     */
64 2
    public function canRead($pFilename)
65
    {
66 2
        File::assertFile($pFilename);
67
68
        // Check if gzlib functions are available
69 2
        if (!function_exists('gzread')) {
70
            throw new Exception('gzlib library is not enabled');
71
        }
72
73
        // Read signature data (first 3 bytes)
74 2
        $fh = fopen($pFilename, 'r');
75 2
        $data = fread($fh, 2);
76 2
        fclose($fh);
77
78 2
        if ($data != chr(0x1F) . chr(0x8B)) {
79
            return false;
80
        }
81
82 2
        return true;
83
    }
84
85
    /**
86
     * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object
87
     *
88
     * @param   string         $pFilename
89
     * @throws  Exception
90
     */
91
    public function listWorksheetNames($pFilename)
92
    {
93
        File::assertFile($pFilename);
94
95
        $xml = new XMLReader();
96
        $xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions());
97
        $xml->setParserProperty(2, true);
98
99
        $worksheetNames = [];
100
        while ($xml->read()) {
101 View Code Duplication
            if ($xml->name == 'gnm:SheetName' && $xml->nodeType == XMLReader::ELEMENT) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
                $xml->read(); //    Move onto the value node
103
                $worksheetNames[] = (string) $xml->value;
104
            } elseif ($xml->name == 'gnm:Sheets') {
105
                //    break out of the loop once we've got our sheet names rather than parse the entire file
106
                break;
107
            }
108
        }
109
110
        return $worksheetNames;
111
    }
112
113
    /**
114
     * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
115
     *
116
     * @param   string     $pFilename
117
     * @throws   Exception
118
     */
119
    public function listWorksheetInfo($pFilename)
120
    {
121
        File::assertFile($pFilename);
122
123
        $xml = new XMLReader();
124
        $xml->xml($this->securityScanFile('compress.zlib://' . realpath($pFilename)), null, \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions());
125
        $xml->setParserProperty(2, true);
126
127
        $worksheetInfo = [];
128
        while ($xml->read()) {
129
            if ($xml->name == 'gnm:Sheet' && $xml->nodeType == XMLReader::ELEMENT) {
130
                $tmpInfo = [
131
                    'worksheetName' => '',
132
                    'lastColumnLetter' => 'A',
133
                    'lastColumnIndex' => 0,
134
                    'totalRows' => 0,
135
                    'totalColumns' => 0,
136
                ];
137
138
                while ($xml->read()) {
139
                    if ($xml->name == 'gnm:Name' && $xml->nodeType == XMLReader::ELEMENT) {
140
                        $xml->read(); //    Move onto the value node
141
                        $tmpInfo['worksheetName'] = (string) $xml->value;
142
                    } elseif ($xml->name == 'gnm:MaxCol' && $xml->nodeType == XMLReader::ELEMENT) {
143
                        $xml->read(); //    Move onto the value node
144
                        $tmpInfo['lastColumnIndex'] = (int) $xml->value;
145
                        $tmpInfo['totalColumns'] = (int) $xml->value + 1;
146 View Code Duplication
                    } elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
147
                        $xml->read(); //    Move onto the value node
148
                        $tmpInfo['totalRows'] = (int) $xml->value + 1;
149
                        break;
150
                    }
151
                }
152
                $tmpInfo['lastColumnLetter'] = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
153
                $worksheetInfo[] = $tmpInfo;
154
            }
155
        }
156
157
        return $worksheetInfo;
158
    }
159
160
    /**
161
     * @param string $filename
162
     */
163 1
    private function gzfileGetContents($filename)
164
    {
165 1
        $file = @gzopen($filename, 'rb');
166 1
        if ($file !== false) {
167 1
            $data = '';
168 1
            while (!gzeof($file)) {
169 1
                $data .= gzread($file, 1024);
170
            }
171 1
            gzclose($file);
172
        }
173
174 1
        return $data;
0 ignored issues
show
Bug introduced by
The variable $data does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
175
    }
176
177
    /**
178
     * Loads Spreadsheet from file
179
     *
180
     * @param     string         $pFilename
181
     * @throws     Exception
182
     * @return     Spreadsheet
183
     */
184 1
    public function load($pFilename)
185
    {
186
        // Create new Spreadsheet
187 1
        $spreadsheet = new Spreadsheet();
188
189
        // Load into this instance
190 1
        return $this->loadIntoExisting($pFilename, $spreadsheet);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->loadIntoEx...ilename, $spreadsheet); (PhpOffice\PhpSpreadsheet\Spreadsheet) is incompatible with the return type declared by the interface PhpOffice\PhpSpreadsheet\Reader\IReader::load of type PhpOffice\PhpSpreadsheet\Reader\PhpSpreadsheet.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
191
    }
192
193
    /**
194
     * Loads from file into Spreadsheet instance
195
     *
196
     * @param     string         $pFilename
197
     * @param    Spreadsheet    $spreadsheet
198
     * @throws     Exception
199
     * @return     Spreadsheet
200
     */
201 1
    public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
202
    {
203 1
        File::assertFile($pFilename);
204
205 1
        $timezoneObj = new DateTimeZone('Europe/London');
0 ignored issues
show
Unused Code introduced by
$timezoneObj is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
206 1
        $GMT = new DateTimeZone('UTC');
0 ignored issues
show
Unused Code introduced by
$GMT is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
207
208 1
        $gFileData = $this->gzfileGetContents($pFilename);
209
210 1
        $xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions());
211 1
        $namespacesMeta = $xml->getNamespaces(true);
212
213 1
        $gnmXML = $xml->children($namespacesMeta['gnm']);
214
215 1
        $docProps = $spreadsheet->getProperties();
216
        //    Document Properties are held differently, depending on the version of Gnumeric
217 1
        if (isset($namespacesMeta['office'])) {
218 1
            $officeXML = $xml->children($namespacesMeta['office']);
219 1
            $officeDocXML = $officeXML->{'document-meta'};
220 1
            $officeDocMetaXML = $officeDocXML->meta;
221
222 1
            foreach ($officeDocMetaXML as $officePropertyData) {
223 1
                $officePropertyDC = [];
224 1
                if (isset($namespacesMeta['dc'])) {
225 1
                    $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
226
                }
227 1
                foreach ($officePropertyDC as $propertyName => $propertyValue) {
228 1
                    $propertyValue = (string) $propertyValue;
229
                    switch ($propertyName) {
230 1
                        case 'title':
231 1
                            $docProps->setTitle(trim($propertyValue));
232 1
                            break;
233 1
                        case 'subject':
234 1
                            $docProps->setSubject(trim($propertyValue));
235 1
                            break;
236 1
                        case 'creator':
237 1
                            $docProps->setCreator(trim($propertyValue));
238 1
                            $docProps->setLastModifiedBy(trim($propertyValue));
239 1
                            break;
240 1 View Code Duplication
                        case 'date':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
241 1
                            $creationDate = strtotime(trim($propertyValue));
242 1
                            $docProps->setCreated($creationDate);
0 ignored issues
show
Documentation introduced by
$creationDate is of type integer, but the function expects a object<PhpOffice\PhpSpre...Document\datetime>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
243 1
                            $docProps->setModified($creationDate);
0 ignored issues
show
Documentation introduced by
$creationDate is of type integer, but the function expects a object<PhpOffice\PhpSpre...Document\datetime>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
244 1
                            break;
245 1
                        case 'description':
246 1
                            $docProps->setDescription(trim($propertyValue));
247 1
                            break;
248
                    }
249
                }
250 1
                $officePropertyMeta = [];
251 1
                if (isset($namespacesMeta['meta'])) {
252 1
                    $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
253
                }
254 1
                foreach ($officePropertyMeta as $propertyName => $propertyValue) {
255 1
                    $attributes = $propertyValue->attributes($namespacesMeta['meta']);
256 1
                    $propertyValue = (string) $propertyValue;
257
                    switch ($propertyName) {
258 1
                        case 'keyword':
259 1
                            $docProps->setKeywords(trim($propertyValue));
260 1
                            break;
261 1
                        case 'initial-creator':
262 1
                            $docProps->setCreator(trim($propertyValue));
263 1
                            $docProps->setLastModifiedBy(trim($propertyValue));
264 1
                            break;
265 1 View Code Duplication
                        case 'creation-date':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
266 1
                            $creationDate = strtotime(trim($propertyValue));
267 1
                            $docProps->setCreated($creationDate);
0 ignored issues
show
Documentation introduced by
$creationDate is of type integer, but the function expects a object<PhpOffice\PhpSpre...Document\datetime>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
268 1
                            $docProps->setModified($creationDate);
0 ignored issues
show
Documentation introduced by
$creationDate is of type integer, but the function expects a object<PhpOffice\PhpSpre...Document\datetime>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
269 1
                            break;
270 1
                        case 'user-defined':
271 1
                            list(, $attrName) = explode(':', $attributes['name']);
272
                            switch ($attrName) {
273 1
                                case 'publisher':
274 1
                                    $docProps->setCompany(trim($propertyValue));
275 1
                                    break;
276 1
                                case 'category':
277 1
                                    $docProps->setCategory(trim($propertyValue));
278 1
                                    break;
279 1
                                case 'manager':
280 1
                                    $docProps->setManager(trim($propertyValue));
281 1
                                    break;
282
                            }
283 1
                            break;
284
                    }
285
                }
286
            }
287
        } elseif (isset($gnmXML->Summary)) {
288
            foreach ($gnmXML->Summary->Item as $summaryItem) {
289
                $propertyName = $summaryItem->name;
290
                $propertyValue = $summaryItem->{'val-string'};
291
                switch ($propertyName) {
292
                    case 'title':
293
                        $docProps->setTitle(trim($propertyValue));
294
                        break;
295
                    case 'comments':
296
                        $docProps->setDescription(trim($propertyValue));
297
                        break;
298
                    case 'keywords':
299
                        $docProps->setKeywords(trim($propertyValue));
300
                        break;
301
                    case 'category':
302
                        $docProps->setCategory(trim($propertyValue));
303
                        break;
304
                    case 'manager':
305
                        $docProps->setManager(trim($propertyValue));
306
                        break;
307
                    case 'author':
308
                        $docProps->setCreator(trim($propertyValue));
309
                        $docProps->setLastModifiedBy(trim($propertyValue));
310
                        break;
311
                    case 'company':
312
                        $docProps->setCompany(trim($propertyValue));
313
                        break;
314
                }
315
            }
316
        }
317
318 1
        $worksheetID = 0;
319 1
        foreach ($gnmXML->Sheets->Sheet as $sheet) {
320 1
            $worksheetName = (string) $sheet->Name;
321 1
            if ((isset($this->loadSheetsOnly)) && (!in_array($worksheetName, $this->loadSheetsOnly))) {
322
                continue;
323
            }
324
325 1
            $maxRow = $maxCol = 0;
326
327
            // Create new Worksheet
328 1
            $spreadsheet->createSheet();
329 1
            $spreadsheet->setActiveSheetIndex($worksheetID);
330
            //    Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
331
            //        cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
332
            //        name in line with the formula, not the reverse
333 1
            $spreadsheet->getActiveSheet()->setTitle($worksheetName, false);
334
335 1
            if ((!$this->readDataOnly) && (isset($sheet->PrintInformation))) {
336 1
                if (isset($sheet->PrintInformation->Margins)) {
337 1
                    foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) {
338 1
                        $marginAttributes = $margin->attributes();
339 1
                        $marginSize = 72 / 100; //    Default
340 1
                        switch ($marginAttributes['PrefUnit']) {
341 1
                            case 'mm':
342 1
                                $marginSize = intval($marginAttributes['Points']) / 100;
343 1
                                break;
344
                        }
345
                        switch ($key) {
346 1
                            case 'top':
347 1
                                $spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize);
348 1
                                break;
349 1
                            case 'bottom':
350 1
                                $spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize);
351 1
                                break;
352 1
                            case 'left':
353 1
                                $spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize);
354 1
                                break;
355 1
                            case 'right':
356 1
                                $spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize);
357 1
                                break;
358 1
                            case 'header':
359 1
                                $spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize);
360 1
                                break;
361 1
                            case 'footer':
362 1
                                $spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize);
363 1
                                break;
364
                        }
365
                    }
366
                }
367
            }
368
369 1
            foreach ($sheet->Cells->Cell as $cell) {
370 1
                $cellAttributes = $cell->attributes();
371 1
                $row = (int) $cellAttributes->Row + 1;
372 1
                $column = (int) $cellAttributes->Col;
373
374 1
                if ($row > $maxRow) {
375 1
                    $maxRow = $row;
376
                }
377 1
                if ($column > $maxCol) {
378 1
                    $maxCol = $column;
379
                }
380
381 1
                $column = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($column);
382
383
                // Read cell?
384 1
                if ($this->getReadFilter() !== null) {
385 1
                    if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) {
386
                        continue;
387
                    }
388
                }
389
390 1
                $ValueType = $cellAttributes->ValueType;
391 1
                $ExprID = (string) $cellAttributes->ExprID;
392 1
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA;
393 1
                if ($ExprID > '') {
394 1
                    if (((string) $cell) > '') {
395 1
                        $this->expressions[$ExprID] = [
396 1
                            'column' => $cellAttributes->Col,
397 1
                            'row' => $cellAttributes->Row,
398 1
                            'formula' => (string) $cell,
399
                        ];
400
                    } else {
401 1
                        $expression = $this->expressions[$ExprID];
402
403 1
                        $cell = $this->referenceHelper->updateFormulaReferences(
404 1
                            $expression['formula'],
405 1
                            'A1',
406 1
                            $cellAttributes->Col - $expression['column'],
407 1
                            $cellAttributes->Row - $expression['row'],
408
                            $worksheetName
409
                        );
410
                    }
411 1
                    $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_FORMULA;
412
                } else {
413
                    switch ($ValueType) {
414 1
                        case '10':        //    NULL
415
                            $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NULL;
416
                            break;
417 1
                        case '20':        //    Boolean
418 1
                            $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_BOOL;
419 1
                            $cell = ($cell == 'TRUE') ? true : false;
420 1
                            break;
421 1
                        case '30':        //    Integer
422
                            $cell = intval($cell);
423
                            // Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case
424 1
                        case '40':        //    Float
425 1
                            $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_NUMERIC;
426 1
                            break;
427 1
                        case '50':        //    Error
428
                            $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_ERROR;
429
                            break;
430 1
                        case '60':        //    String
431 1
                            $type = \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING;
432 1
                            break;
433 1
                        case '70':        //    Cell Range
434 1
                        case '80':        //    Array
435
                    }
436
                }
437 1
                $spreadsheet->getActiveSheet()->getCell($column . $row)->setValueExplicit($cell, $type);
438
            }
439
440 1
            if ((!$this->readDataOnly) && (isset($sheet->Objects))) {
441 1
                foreach ($sheet->Objects->children('gnm', true) as $key => $comment) {
442 1
                    $commentAttributes = $comment->attributes();
443
                    //    Only comment objects are handled at the moment
444 1
                    if ($commentAttributes->Text) {
445 1
                        $spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)->setAuthor((string) $commentAttributes->Author)->setText($this->parseRichText((string) $commentAttributes->Text));
446
                    }
447
                }
448
            }
449 1
            foreach ($sheet->Styles->StyleRegion as $styleRegion) {
450 1
                $styleAttributes = $styleRegion->attributes();
451 1
                if (($styleAttributes['startRow'] <= $maxRow) &&
452 1
                    ($styleAttributes['startCol'] <= $maxCol)) {
453 1
                    $startColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
454 1
                    $startRow = $styleAttributes['startRow'] + 1;
455
456 1
                    $endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol'];
457 1
                    $endColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($endColumn);
458 1
                    $endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow'];
459 1
                    $endRow += 1;
460 1
                    $cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow;
461
462 1
                    $styleAttributes = $styleRegion->Style->attributes();
463
464
                    //    We still set the number format mask for date/time values, even if readDataOnly is true
465 1
                    if ((!$this->readDataOnly) ||
466 1
                        (\PhpOffice\PhpSpreadsheet\Shared\Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) {
467 1
                        $styleArray = [];
468 1
                        $styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
469
                        //    If readDataOnly is false, we set all formatting information
470 1
                        if (!$this->readDataOnly) {
471 1
                            switch ($styleAttributes['HAlign']) {
472 1
                                case '1':
473 1
                                    $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL;
474 1
                                    break;
475 1
                                case '2':
476 1
                                    $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT;
477 1
                                    break;
478 1
                                case '4':
479 1
                                    $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT;
480 1
                                    break;
481 1
                                case '8':
482 1
                                    $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER;
483 1
                                    break;
484
                                case '16':
485
                                case '64':
486
                                    $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS;
487
                                    break;
488
                                case '32':
489
                                    $styleArray['alignment']['horizontal'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY;
490
                                    break;
491
                            }
492
493 1
                            switch ($styleAttributes['VAlign']) {
494 1
                                case '1':
495 1
                                    $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP;
496 1
                                    break;
497 1
                                case '2':
498 1
                                    $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM;
499 1
                                    break;
500 1
                                case '4':
501 1
                                    $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER;
502 1
                                    break;
503
                                case '8':
504
                                    $styleArray['alignment']['vertical'] = \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY;
505
                                    break;
506
                            }
507
508 1
                            $styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? true : false;
509 1
                            $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false;
510 1
                            $styleArray['alignment']['indent'] = (intval($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0;
511
512 1
                            $RGB = self::parseGnumericColour($styleAttributes['Fore']);
513 1
                            $styleArray['font']['color']['rgb'] = $RGB;
514 1
                            $RGB = self::parseGnumericColour($styleAttributes['Back']);
515 1
                            $shade = $styleAttributes['Shade'];
516 1
                            if (($RGB != '000000') || ($shade != '0')) {
517 1
                                $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB;
518 1
                                $RGB2 = self::parseGnumericColour($styleAttributes['PatternColor']);
519 1
                                $styleArray['fill']['endcolor']['rgb'] = $RGB2;
520
                                switch ($shade) {
521 1
                                    case '1':
522 1
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID;
523 1
                                        break;
524 1
                                    case '2':
525
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR;
526
                                        break;
527 1
                                    case '3':
528
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH;
529
                                        break;
530 1
                                    case '4':
531
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKDOWN;
532
                                        break;
533 1
                                    case '5':
534
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRAY;
535
                                        break;
536 1
                                    case '6':
537 1
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRID;
538 1
                                        break;
539 1
                                    case '7':
540 1
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKHORIZONTAL;
541 1
                                        break;
542 1
                                    case '8':
543
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKTRELLIS;
544
                                        break;
545 1
                                    case '9':
546
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKUP;
547
                                        break;
548 1
                                    case '10':
549
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKVERTICAL;
550
                                        break;
551 1
                                    case '11':
552
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625;
553
                                        break;
554 1
                                    case '12':
555
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125;
556
                                        break;
557 1
                                    case '13':
558
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTDOWN;
559
                                        break;
560 1
                                    case '14':
561
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRAY;
562
                                        break;
563 1
                                    case '15':
564
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRID;
565
                                        break;
566 1
                                    case '16':
567
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTHORIZONTAL;
568
                                        break;
569 1
                                    case '17':
570
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS;
571
                                        break;
572 1
                                    case '18':
573
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTUP;
574
                                        break;
575 1
                                    case '19':
576
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTVERTICAL;
577
                                        break;
578 1
                                    case '20':
579
                                        $styleArray['fill']['type'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_MEDIUMGRAY;
580
                                        break;
581
                                }
582
                            }
583
584 1
                            $fontAttributes = $styleRegion->Style->Font->attributes();
585 1
                            $styleArray['font']['name'] = (string) $styleRegion->Style->Font;
586 1
                            $styleArray['font']['size'] = intval($fontAttributes['Unit']);
587 1
                            $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false;
588 1
                            $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false;
589 1
                            $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false;
590 1
                            switch ($fontAttributes['Underline']) {
591 1
                                case '1':
592 1
                                    $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE;
593 1
                                    break;
594 1
                                case '2':
595 1
                                    $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE;
596 1
                                    break;
597 1
                                case '3':
598 1
                                    $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLEACCOUNTING;
599 1
                                    break;
600 1
                                case '4':
601 1
                                    $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLEACCOUNTING;
602 1
                                    break;
603
                                default:
604 1
                                    $styleArray['font']['underline'] = \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE;
605 1
                                    break;
606
                            }
607 1
                            switch ($fontAttributes['Script']) {
608 1
                                case '1':
609 1
                                    $styleArray['font']['superScript'] = true;
610 1
                                    break;
611 1
                                case '-1':
612 1
                                    $styleArray['font']['subScript'] = true;
613 1
                                    break;
614
                            }
615
616 1
                            if (isset($styleRegion->Style->StyleBorder)) {
617 1 View Code Duplication
                                if (isset($styleRegion->Style->StyleBorder->Top)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
618 1
                                    $styleArray['borders']['top'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Top->attributes());
619
                                }
620 1 View Code Duplication
                                if (isset($styleRegion->Style->StyleBorder->Bottom)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
621 1
                                    $styleArray['borders']['bottom'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Bottom->attributes());
622
                                }
623 1 View Code Duplication
                                if (isset($styleRegion->Style->StyleBorder->Left)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
624 1
                                    $styleArray['borders']['left'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Left->attributes());
625
                                }
626 1 View Code Duplication
                                if (isset($styleRegion->Style->StyleBorder->Right)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
627 1
                                    $styleArray['borders']['right'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Right->attributes());
628
                                }
629 1
                                if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) {
630 1
                                    $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
631 1
                                    $styleArray['borders']['diagonaldirection'] = \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH;
632
                                } elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) {
633 1
                                    $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
634 1
                                    $styleArray['borders']['diagonaldirection'] = \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_UP;
635
                                } elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) {
636 1
                                    $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes());
637 1
                                    $styleArray['borders']['diagonaldirection'] = \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_DOWN;
638
                                }
639
                            }
640 1
                            if (isset($styleRegion->Style->HyperLink)) {
641
                                //    TO DO
642 1
                                $hyperlink = $styleRegion->Style->HyperLink->attributes();
0 ignored issues
show
Unused Code introduced by
$hyperlink is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
643
                            }
644
                        }
645 1
                        $spreadsheet->getActiveSheet()->getStyle($cellRange)->applyFromArray($styleArray);
646
                    }
647
                }
648
            }
649
650 1
            if ((!$this->readDataOnly) && (isset($sheet->Cols))) {
651
                //    Column Widths
652 1
                $columnAttributes = $sheet->Cols->attributes();
653 1
                $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4;
654 1
                $c = 0;
655 1
                foreach ($sheet->Cols->ColInfo as $columnOverride) {
656 1
                    $columnAttributes = $columnOverride->attributes();
657 1
                    $column = $columnAttributes['No'];
658 1
                    $columnWidth = $columnAttributes['Unit'] / 5.4;
659 1
                    $hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false;
660 1
                    $columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1;
661 1
                    while ($c < $column) {
662 1
                        $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
663 1
                        ++$c;
664
                    }
665 1
                    while (($c < ($column + $columnCount)) && ($c <= $maxCol)) {
666 1
                        $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setWidth($columnWidth);
667 1
                        if ($hidden) {
668 1
                            $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setVisible(false);
669
                        }
670 1
                        ++$c;
671
                    }
672
                }
673 1
                while ($c <= $maxCol) {
674
                    $spreadsheet->getActiveSheet()->getColumnDimension(\PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
675
                    ++$c;
676
                }
677
            }
678
679 1
            if ((!$this->readDataOnly) && (isset($sheet->Rows))) {
680
                //    Row Heights
681 1
                $rowAttributes = $sheet->Rows->attributes();
682 1
                $defaultHeight = $rowAttributes['DefaultSizePts'];
683 1
                $r = 0;
684
685 1
                foreach ($sheet->Rows->RowInfo as $rowOverride) {
686 1
                    $rowAttributes = $rowOverride->attributes();
687 1
                    $row = $rowAttributes['No'];
688 1
                    $rowHeight = $rowAttributes['Unit'];
689 1
                    $hidden = ((isset($rowAttributes['Hidden'])) && ($rowAttributes['Hidden'] == '1')) ? true : false;
690 1
                    $rowCount = (isset($rowAttributes['Count'])) ? $rowAttributes['Count'] : 1;
691 1
                    while ($r < $row) {
692 1
                        ++$r;
693 1
                        $spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight);
694
                    }
695 1
                    while (($r < ($row + $rowCount)) && ($r < $maxRow)) {
696 1
                        ++$r;
697 1
                        $spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($rowHeight);
698 1
                        if ($hidden) {
699
                            $spreadsheet->getActiveSheet()->getRowDimension($r)->setVisible(false);
700
                        }
701
                    }
702
                }
703 1
                while ($r < $maxRow) {
704
                    ++$r;
705
                    $spreadsheet->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight);
706
                }
707
            }
708
709
            //    Handle Merged Cells in this worksheet
710 1
            if (isset($sheet->MergedRegions)) {
711 1
                foreach ($sheet->MergedRegions->Merge as $mergeCells) {
712 1
                    if (strpos($mergeCells, ':') !== false) {
713 1
                        $spreadsheet->getActiveSheet()->mergeCells($mergeCells);
714
                    }
715
                }
716
            }
717
718 1
            ++$worksheetID;
719
        }
720
721
        //    Loop through definedNames (global named ranges)
722 1
        if (isset($gnmXML->Names)) {
723 1
            foreach ($gnmXML->Names->Name as $namedRange) {
724 1
                $name = (string) $namedRange->name;
725 1
                $range = (string) $namedRange->value;
726 1
                if (stripos($range, '#REF!') !== false) {
727
                    continue;
728
                }
729
730 1
                $range = explode('!', $range);
731 1
                $range[0] = trim($range[0], "'");
732 1
                if ($worksheet = $spreadsheet->getSheetByName($range[0])) {
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $worksheet is correct as $spreadsheet->getSheetByName($range[0]) (which targets PhpOffice\PhpSpreadsheet...sheet::getSheetByName()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
733 1
                    $extractedRange = str_replace('$', '', $range[1]);
734 1
                    $spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange($name, $worksheet, $extractedRange));
735
                }
736
            }
737
        }
738
739
        // Return
740 1
        return $spreadsheet;
741
    }
742
743 1
    private static function parseBorderAttributes($borderAttributes)
744
    {
745 1
        $styleArray = [];
746 1
        if (isset($borderAttributes['Color'])) {
747 1
            $styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes['Color']);
748
        }
749
750 1
        switch ($borderAttributes['Style']) {
751 1
            case '0':
752
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE;
753
                break;
754 1
            case '1':
755 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN;
756 1
                break;
757 1
            case '2':
758 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM;
759 1
                break;
760 1
            case '3':
761
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT;
762
                break;
763 1
            case '4':
764 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED;
765 1
                break;
766 1
            case '5':
767 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK;
768 1
                break;
769 1
            case '6':
770 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE;
771 1
                break;
772 1
            case '7':
773 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED;
774 1
                break;
775 1
            case '8':
776 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED;
777 1
                break;
778 1
            case '9':
779 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT;
780 1
                break;
781 1
            case '10':
782 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT;
783 1
                break;
784 1
            case '11':
785 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT;
786 1
                break;
787 1
            case '12':
788 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT;
789 1
                break;
790 1
            case '13':
791 1
                $styleArray['style'] = \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT;
792 1
                break;
793
        }
794
795 1
        return $styleArray;
796
    }
797
798 1
    private function parseRichText($is = '')
799
    {
800 1
        $value = new \PhpOffice\PhpSpreadsheet\RichText();
801 1
        $value->createText($is);
802
803 1
        return $value;
804
    }
805
806 1
    private static function parseGnumericColour($gnmColour)
807
    {
808 1
        list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
809 1
        $gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2);
810 1
        $gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2);
811 1
        $gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2);
812
813 1
        return $gnmR . $gnmG . $gnmB;
814
    }
815
}
816