Completed
Push — 4.1 ( dea10e...c5e1f2 )
by Andrea
62:40
created

TabellaXls::setColumnAutowidth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Fi\CoreBundle\Utils\Export;
4
5
use PhpOffice\PhpSpreadsheet\Spreadsheet;
6
use PhpOffice\PhpSpreadsheet\Writer\Xls;
7
use PhpOffice\PhpSpreadsheet\Style\Fill;
8
use PhpOffice\PhpSpreadsheet\Style\Border;
9
use Fi\CoreBundle\Utils\Entity\DoctrineFieldReader;
10
11
class TabellaXls
12
{
13 2
14
    public function esportaexcel($parametri = array())
15 2
    {
16 2
        set_time_limit(960);
17
        ini_set('memory_limit', '2048M');
18
19 2
        //Creare un nuovo file
20 2
        $spreadsheet = new Spreadsheet();
21 2
        $objPHPExcel = new Xls($spreadsheet);
22
        $spreadsheet->setActiveSheetIndex(0);
23
24 2
        // Set properties
25 2
        $spreadsheet->getProperties()->setCreator('Comune di Firenze');
26
        $spreadsheet->getProperties()->setLastModifiedBy('Comune di Firenze');
27
28 2
29 2
        $header = $parametri['parametritabella'];
30
        $rows = $parametri['recordstabella'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
31 2
        //Scrittura su file
32 2
        $sheet = $spreadsheet->getActiveSheet();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
33 2
        $titolosheet = 'Esportazione ' . $parametri['nomecontroller'];
34 2
        $sheet->setTitle(substr($titolosheet, 0, 30));
35
        $sheet->getParent()->getDefaultStyle()->getFont()->setName('Verdana');
36 2
37
        $this->printHeaderXls($header, $sheet);
38 2
39
        $this->printBodyXls($header, $rows, $sheet);
40
41 2
        //Si crea un oggetto
42
        $todaydate = date('d-m-y');
43 2
44 2
        $filename = 'Exportazione';
45 2
        $filename = $filename . '-' . $todaydate . '-' . strtoupper(md5(uniqid(rand(), true)));
46 2
        $filename = $filename . '.xls';
47
        $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename;
48 2
49
        if (file_exists($filename)) {
50
            unlink($filename);
51
        }
52 2
53
        $objPHPExcel->save($filename);
54 2
55
        return $filename;
56 2
    }
57
58 2
    private function printHeaderXls($testata, $sheet)
59 2
    {
60 2
        $indicecolonnaheader = 1;
61 2
        $letteracolonna = 0;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
62
        foreach ($testata as $modellocolonna) {
63 2
            if ($modellocolonna["escluso"] === false) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal escluso does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
64 2
                //Si imposta la larghezza delle colonne
65 2
                $letteracolonna = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($indicecolonnaheader);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
66 2
                $width = (int) $modellocolonna['larghezza'] / 7;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 20 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
67 2
                $indicecolonnaheadertitle = $modellocolonna['etichetta'];
68 2
                $coltitle = strtoupper($indicecolonnaheadertitle);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 17 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
69
                $sheet->setCellValueByColumnAndRow($indicecolonnaheader, 1, $coltitle);
70 2
                $sheet->getColumnDimension($letteracolonna)->setWidth($width);
71
72
                ++$indicecolonnaheader;
73
            }
74 2
        }
75
76
        //Imposta lo stile per l'intestazione un po più decente
77
        $this->setHeaderStyle($sheet, $indicecolonnaheader - 1);
78 2
79 2
80
        $sheet->getRowDimension('1')->setRowHeight(20);
81
    }
82
83
    private function printBodyXls($header, $rows, $sheet)
84
    {
85
        $row = 2;
86 2
        foreach ($rows as $riga) {
87
            $col = 1;
88
            foreach ($header as $colonnatestata => $valorecolonnatestata) {
89 2
                if ($valorecolonnatestata["escluso"] === false) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal escluso does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
90 2
                    $dfr = new DoctrineFieldReader();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
91 2
                    $oggetto = $dfr->getField2Object($colonnatestata, $riga);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
92
                    $valorecampo = $dfr->object2view($oggetto, $valorecolonnatestata["tipocampo"]);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal tipocampo does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
93 2
                    if ($valorecampo === '' || $valorecampo === null) {
94 2
                        $col = $col + 1;
0 ignored issues
show
Coding Style introduced by
Increment operators should be used where possible; found "$col = $col + 1;" but expected "$col++"
Loading history...
95 2
                        continue;
96 2
                    }
97 2
                    $sheet->setCellValueByColumnAndRow($col, $row, $this->getValueCell($valorecolonnatestata["tipocampo"], $valorecampo));
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal tipocampo does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
98 2
                    $col = $col + 1;
0 ignored issues
show
Coding Style introduced by
Increment operators should be used where possible; found "$col = $col + 1;" but expected "$col++"
Loading history...
99 2
                }
100 2
            }
101 2
            $sheet->getRowDimension($row)->setRowHeight(18);
102 2
            ++$row;
103 2
        }
104
105 2
        $col = 1;
106 2
        //Si impostano i formati cella in base al tipo di dato contenuto
107
        foreach ($header as $colonnatestata => $valorecolonnatestata) {
108
            if ($valorecolonnatestata["escluso"] === false) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal escluso does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
109 2
                $this->setCellColumnFormat($sheet, $col, $row - 1, $valorecolonnatestata["tipocampo"]);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal tipocampo does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
110 2
                $this->setColumnAutowidth($sheet, $col);
111
                $col = $col + 1;
0 ignored issues
show
Coding Style introduced by
Increment operators should be used where possible; found "$col = $col + 1;" but expected "$col++"
Loading history...
112
            }
113 2
        }
114
    }
115 2
116 2
    private function setHeaderStyle($sheet, $indiceultimacolonna)
117 2
    {
118 2
        $letteraultimacolonna = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($indiceultimacolonna);
119
        $styleArray = [
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
120
            'font' => [
121 2
                'bold' => true,
122 2
            ],
123
            'alignment' => [
124 2
                'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
125 2
            ],
126 2
            'borders' => [
127 1
                'allBorders' => [
128 1
                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
129 1
                ],
130 1
            ],
131 1
            'fill' => [
132 1
                'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
133 2
                'startColor' => [
134 1
                    'argb' => 'e5e5e5e5',
135 1
                ],
136 1
            ],
137 1
        ];
138 1
139 1
        $sheet->getStyle('A1:' . $letteraultimacolonna . '1')->applyFromArray($styleArray);
140 1
    }
141 1
142
    private function getValueCell($tipocampo, $valorecella)
143 2
    {
144 2
        $valore = null;
145
        switch ($tipocampo) {
146 2
            case 'date':
147
                $d = (int) substr($valorecella, 0, 2);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
148 2
                $m = (int) substr($valorecella, 3, 2);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
149
                $y = (int) substr($valorecella, 6, 4);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
150 2
                $t_date = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($y, $m, $d);
151 2
                $valore = $t_date;
152 2
                break;
153 1
            case 'datetime':
154 1
                $d = (int) substr($valorecella, 0, 2);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
155 1
                $m = (int) substr($valorecella, 3, 2);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
156 1
                $y = (int) substr($valorecella, 6, 4);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
157 2
                $h = (int) substr($valorecella, 11, 2);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
158 2
                $i = (int) substr($valorecella, 14, 2);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
159 2
                $t_date = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($y, $m, $d, $h, $i, 0);
160 2
                $valore = $t_date;
161 2
                break;
162 2
            default:
163 2
                $valore = $valorecella;
164 2
                break;
165 2
        }
166 2
        return $valore;
167 2
    }
168
169
    private function setCellColumnFormat($sheet, $indicecolonna, $lastrow, $tipocampo)
170
    {
171
        $letteracolonna = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($indicecolonna);
172 2
        switch ($tipocampo) {
173 1
            case 'text':
174 1
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
175 1
                        ->getNumberFormat()
176 1
                        ->setFormatCode("@");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal @ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
177 2
                break;
178
            case 'string':
179
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
180
                        ->getNumberFormat()
181
                        ->setFormatCode("@");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal @ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
182 2
                break;
183
            case 'integer':
184 1
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
185 1
                        ->getNumberFormat()
186 1
                        ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER);
187 1
                break;
188 2
            case 'float':
189 1
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
190 1
                        ->getNumberFormat()
191 1
                        ->setFormatCode('#,##0.00');
192 1
                break;
193
            case 'decimal':
194 2
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
195 2
                        ->getNumberFormat()
196 2
                        ->setFormatCode('#,##0.00');
197 2
                break;
198
            case 'number':
199 2
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
200
                        ->getNumberFormat()
201
                        ->setFormatCode('#,##0.00');
202
                break;
203
            case 'datetime':
204
                //\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYYSLASH
205
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
206
                        ->getNumberFormat()
207
                        ->setFormatCode("dd/mm/yyyy hh:mm:ss");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal dd/mm/yyyy hh:mm:ss does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
208
                break;
209
            case 'date':
210
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
211
                        ->getNumberFormat()
212
                        ->setFormatCode("dd/mm/yyyy");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal dd/mm/yyyy does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
213
                break;
214
            default:
215
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
216
                        ->getNumberFormat()
217
                        ->setFormatCode("@");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal @ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
218
                break;
219
        }
220
    }
221
222
    private function setColumnAutowidth($sheet, $indicecolonna)
223
    {
224
        $letteracolonna = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($indicecolonna);
225
        $sheet->getColumnDimension($letteracolonna)->setAutoSize(true);
226
    }
227
228
}
229