Passed
Push — develop ( 541cad...3e7b2f )
by Andrea
64:39
created

TabellaXls::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\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 Cdf\BiCoreBundle\Utils\Entity\DoctrineFieldReader;
10
11
class TabellaXls
12
{
13
    public function __construct($container)
14 3
    {
15
        $this->container = $container;
16 3
    }
17 3
    
18
    public function esportaexcel($parametri = array())
19
    {
20 3
        set_time_limit(960);
21 3
        ini_set('memory_limit', '2048M');
22 3
23
        //Creare un nuovo file
24
        $spreadsheet = new Spreadsheet();
25 3
        $objPHPExcel = new Xls($spreadsheet);
26 3
        $spreadsheet->setActiveSheetIndex(0);
27
28
        // Set properties
29 3
        $spreadsheet->getProperties()->setCreator('Comune di Firenze');
30 3
        $spreadsheet->getProperties()->setLastModifiedBy('Comune di Firenze');
31
32 3
33 3
        $header = $parametri['parametritabella'];
34 3
        $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...
35 3
        //Scrittura su file
36
        $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...
37 3
        $titolosheet = 'Esportazione ' . $parametri['nomecontroller'];
38
        $sheet->setTitle(substr($titolosheet, 0, 30));
39 3
        $sheet->getParent()->getDefaultStyle()->getFont()->setName('Verdana');
40
41
        $this->printHeaderXls($header, $sheet);
42 3
43
        $this->printBodyXls($header, $rows, $sheet);
44 3
45 3
        //Si crea un oggetto
46 3
        $todaydate = date('d-m-y');
47 3
48
        $filename = 'Exportazione';
49 3
        $filename = $filename . '-' . $todaydate . '-' . strtoupper(md5(uniqid(rand(), true)));
50
        $filename = $filename . '.xls';
51
        $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename;
52
53 3
        if (file_exists($filename)) {
54
            unlink($filename);
55 3
        }
56
57
        $objPHPExcel->save($filename);
58 3
59
        return $filename;
60 3
    }
61 3
62 3
    private function printHeaderXls($testata, $sheet)
63 3
    {
64
        $indicecolonnaheader = 1;
65 3
        $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...
66 3
        foreach ($testata as $modellocolonna) {
67 3
            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...
68 3
                //Si imposta la larghezza delle colonne
69 3
                $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...
70 3
                $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...
71
                $indicecolonnaheadertitle = $modellocolonna['etichetta'];
72 3
                $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...
73
                $sheet->setCellValueByColumnAndRow($indicecolonnaheader, 1, $coltitle);
74
                $sheet->getColumnDimension($letteracolonna)->setWidth($width);
75
76
                ++$indicecolonnaheader;
77 3
            }
78
        }
79
80 3
        //Imposta lo stile per l'intestazione un po più decente
81 3
        $this->setHeaderStyle($sheet, $indicecolonnaheader - 1);
82
83 3
84
        $sheet->getRowDimension('1')->setRowHeight(20);
85 3
    }
86 3
87 3
    private function printBodyXls($header, $rows, $sheet)
88 3
    {
89 3
        $row = 2;
90 3
        foreach ($rows as $riga) {
91 3
            $col = 1;
92 3
            foreach ($header as $colonnatestata => $valorecolonnatestata) {
93 3
                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...
94 3
                    $dfr = new DoctrineFieldReader($this->container);
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...
95 3
                    $decodiche = isset($valorecolonnatestata["decodifiche"])?$valorecolonnatestata["decodifiche"]:null;
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...
Coding Style Comprehensibility introduced by
The string literal decodifiche 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...
96 3
                    $oggetto = $dfr->getField2Object($colonnatestata, $riga, $decodiche);
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...
97
                    $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...
98 3
                    if ($valorecampo === '' || $valorecampo === null) {
99 3
                        $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...
100
                        continue;
101
                    }
102 3
                    $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...
103 3
                    $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...
104
                }
105
            }
106 3
            $sheet->getRowDimension($row)->setRowHeight(18);
107
            ++$row;
108 3
        }
109 3
110 3
        $col = 1;
111 3
        //Si impostano i formati cella in base al tipo di dato contenuto
112 3
        foreach ($header as $colonnatestata => $valorecolonnatestata) {
113
            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...
114
                $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...
115 3
                $this->setColumnAutowidth($sheet, $col);
116
                $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...
117 3
            }
118
        }
119 3
    }
120
121 3
    private function setHeaderStyle($sheet, $indiceultimacolonna)
122
    {
123
        $letteraultimacolonna = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($indiceultimacolonna);
124
        $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...
125 3
            'font' => [
126
                'bold' => true,
127
            ],
128
            'alignment' => [
129 3
                'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
130
            ],
131
            'borders' => [
132
                'allBorders' => [
133 3
                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
134
                ],
135
            ],
136
            'fill' => [
137
                'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
138
                'startColor' => [
139
                    'argb' => 'e5e5e5e5',
140 3
                ],
141 3
            ],
142
        ];
143 3
144
        $sheet->getStyle('A1:' . $letteraultimacolonna . '1')->applyFromArray($styleArray);
145 3
    }
146 3
147 3
    private function getValueCell($tipocampo, $valorecella)
148 1
    {
149 1
        $valore = null;
150 1
        switch ($tipocampo) {
151 1
            case 'date':
152 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...
153 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...
154 3
                $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...
155 2
                $t_date = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($y, $m, $d);
156 2
                $valore = $t_date;
157 2
                break;
158 2
            case 'datetime':
159 2
                $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...
160 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...
161 2
                $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...
162 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...
163
                $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...
164 3
                $t_date = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($y, $m, $d, $h, $i, 0);
165 3
                $valore = $t_date;
166
                break;
167 3
            default:
168
                $valore = $valorecella;
169
                break;
170 3
        }
171
        return $valore;
172 3
    }
173 3
174 3
    private function setCellColumnFormat($sheet, $indicecolonna, $lastrow, $tipocampo)
175 1
    {
176 1
        $letteracolonna = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($indicecolonna);
177 1
        switch ($tipocampo) {
178 1
            case 'text':
179 3
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
180 3
                        ->getNumberFormat()
181 3
                        ->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 3
                break;
183 3
            case 'string':
184 3
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
185 3
                        ->getNumberFormat()
186 3
                        ->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...
187 3
                break;
188 3
            case 'integer':
189 3
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
190
                        ->getNumberFormat()
191
                        ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER);
192
                break;
193
            case 'float':
194 3
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
195 1
                        ->getNumberFormat()
196 1
                        ->setFormatCode('#,##0.00');
197 1
                break;
198 1
            case 'decimal':
199 3
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
200
                        ->getNumberFormat()
201
                        ->setFormatCode('#,##0.00');
202
                break;
203
            case 'number':
204 3
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
205
                        ->getNumberFormat()
206 2
                        ->setFormatCode('#,##0.00');
207 2
                break;
208 2
            case 'datetime':
209 2
                //\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYYSLASH
210 3
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
211 1
                        ->getNumberFormat()
212 1
                        ->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...
213 1
                break;
214 1
            case 'date':
215
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
216 3
                        ->getNumberFormat()
217 3
                        ->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...
218 3
                break;
219 3
            default:
220
                $sheet->getStyle($letteracolonna . '2:' . $letteracolonna . $lastrow)
221 3
                        ->getNumberFormat()
222
                        ->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...
223 3
                break;
224
        }
225 3
    }
226 3
227 3
    private function setColumnAutowidth($sheet, $indicecolonna)
228
    {
229
        $letteracolonna = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($indicecolonna);
230
        $sheet->getColumnDimension($letteracolonna)->setAutoSize(true);
231
    }
232
}
233