Skip to content

Commit 2adaad3

Browse files
author
Mark Baker
authored
Minor improvements (#1028)
* Initial tweaks * Move signatures for abstract BaseReader methods to the IReader interface * Appease the great whitespace gods
1 parent ca56fd2 commit 2adaad3

File tree

6 files changed

+110
-88
lines changed

6 files changed

+110
-88
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
]
4040
},
4141
"require": {
42-
"php": "^7.0",
42+
"php": "5.6|^7.0",
4343
"ext-ctype": "*",
4444
"ext-dom": "*",
4545
"ext-gd": "*",

samples/Basic/31_Document_properties_write.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
5757
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
5858
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
59-
$formattedValue = date('d-M-Y H:i:s', $propertyValue);
59+
$formattedValue = date('d-M-Y H:i:s', (int) $propertyValue);
6060
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
6161
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
6262
} else {

samples/Basic/31_Document_properties_write_xls.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
5757
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
5858
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
59-
$formattedValue = date('d-M-Y H:i:s', $propertyValue);
59+
$formattedValue = date('d-M-Y H:i:s', (int) $propertyValue);
6060
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
6161
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
6262
} else {

samples/Basic/40_Duplicate_style.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
}
3232
$d = microtime(true) - $t;
33-
$helper->log('Add data (end) . time: ' . round($d . 2) . ' s');
33+
$helper->log('Add data (end) . time: ' . round((string) ($d . 2)) . ' s');
3434

3535
// Save
3636
$helper->write($spreadsheet, __FILE__);

src/PhpSpreadsheet/Reader/BaseReader.php

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -60,113 +60,47 @@ public function __construct()
6060
$this->readFilter = new DefaultReadFilter();
6161
}
6262

63-
/**
64-
* Read data only?
65-
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
66-
* If false (the default) it will read data and formatting.
67-
*
68-
* @return bool
69-
*/
7063
public function getReadDataOnly()
7164
{
7265
return $this->readDataOnly;
7366
}
7467

75-
/**
76-
* Set read data only
77-
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
78-
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
79-
*
80-
* @param bool $pValue
81-
*
82-
* @return IReader
83-
*/
8468
public function setReadDataOnly($pValue)
8569
{
8670
$this->readDataOnly = (bool) $pValue;
8771

8872
return $this;
8973
}
9074

91-
/**
92-
* Read empty cells?
93-
* If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
94-
* If false it will not read data for cells containing a null value or an empty string.
95-
*
96-
* @return bool
97-
*/
9875
public function getReadEmptyCells()
9976
{
10077
return $this->readEmptyCells;
10178
}
10279

103-
/**
104-
* Set read empty cells
105-
* Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
106-
* Set to false to advise the Reader to ignore cells containing a null value or an empty string.
107-
*
108-
* @param bool $pValue
109-
*
110-
* @return IReader
111-
*/
11280
public function setReadEmptyCells($pValue)
11381
{
11482
$this->readEmptyCells = (bool) $pValue;
11583

11684
return $this;
11785
}
11886

119-
/**
120-
* Read charts in workbook?
121-
* If this is true, then the Reader will include any charts that exist in the workbook.
122-
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
123-
* If false (the default) it will ignore any charts defined in the workbook file.
124-
*
125-
* @return bool
126-
*/
12787
public function getIncludeCharts()
12888
{
12989
return $this->includeCharts;
13090
}
13191

132-
/**
133-
* Set read charts in workbook
134-
* Set to true, to advise the Reader to include any charts that exist in the workbook.
135-
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
136-
* Set to false (the default) to discard charts.
137-
*
138-
* @param bool $pValue
139-
*
140-
* @return IReader
141-
*/
14292
public function setIncludeCharts($pValue)
14393
{
14494
$this->includeCharts = (bool) $pValue;
14595

14696
return $this;
14797
}
14898

149-
/**
150-
* Get which sheets to load
151-
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
152-
* indicating that all worksheets in the workbook should be loaded.
153-
*
154-
* @return mixed
155-
*/
15699
public function getLoadSheetsOnly()
157100
{
158101
return $this->loadSheetsOnly;
159102
}
160103

161-
/**
162-
* Set which sheets to load.
163-
*
164-
* @param mixed $value
165-
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
166-
* If NULL, then it tells the Reader to read all worksheets in the workbook
167-
*
168-
* @return IReader
169-
*/
170104
public function setLoadSheetsOnly($value)
171105
{
172106
if ($value === null) {
@@ -178,36 +112,18 @@ public function setLoadSheetsOnly($value)
178112
return $this;
179113
}
180114

181-
/**
182-
* Set all sheets to load
183-
* Tells the Reader to load all worksheets from the workbook.
184-
*
185-
* @return IReader
186-
*/
187115
public function setLoadAllSheets()
188116
{
189117
$this->loadSheetsOnly = null;
190118

191119
return $this;
192120
}
193121

194-
/**
195-
* Read filter.
196-
*
197-
* @return IReadFilter
198-
*/
199122
public function getReadFilter()
200123
{
201124
return $this->readFilter;
202125
}
203126

204-
/**
205-
* Set read filter.
206-
*
207-
* @param IReadFilter $pValue
208-
*
209-
* @return IReader
210-
*/
211127
public function setReadFilter(IReadFilter $pValue)
212128
{
213129
$this->readFilter = $pValue;

src/PhpSpreadsheet/Reader/IReader.php

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,112 @@ public function __construct();
1818
*/
1919
public function canRead($pFilename);
2020

21+
/**
22+
* Read data only?
23+
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
24+
* If false (the default) it will read data and formatting.
25+
*
26+
* @return bool
27+
*/
28+
public function getReadDataOnly();
29+
30+
/**
31+
* Set read data only
32+
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
33+
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
34+
*
35+
* @param bool $pValue
36+
*
37+
* @return IReader
38+
*/
39+
public function setReadDataOnly($pValue);
40+
41+
/**
42+
* Read empty cells?
43+
* If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
44+
* If false it will not read data for cells containing a null value or an empty string.
45+
*
46+
* @return bool
47+
*/
48+
public function getReadEmptyCells();
49+
50+
/**
51+
* Set read empty cells
52+
* Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
53+
* Set to false to advise the Reader to ignore cells containing a null value or an empty string.
54+
*
55+
* @param bool $pValue
56+
*
57+
* @return IReader
58+
*/
59+
public function setReadEmptyCells($pValue);
60+
61+
/**
62+
* Read charts in workbook?
63+
* If this is true, then the Reader will include any charts that exist in the workbook.
64+
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
65+
* If false (the default) it will ignore any charts defined in the workbook file.
66+
*
67+
* @return bool
68+
*/
69+
public function getIncludeCharts();
70+
71+
/**
72+
* Set read charts in workbook
73+
* Set to true, to advise the Reader to include any charts that exist in the workbook.
74+
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
75+
* Set to false (the default) to discard charts.
76+
*
77+
* @param bool $pValue
78+
*
79+
* @return IReader
80+
*/
81+
public function setIncludeCharts($pValue);
82+
83+
/**
84+
* Get which sheets to load
85+
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
86+
* indicating that all worksheets in the workbook should be loaded.
87+
*
88+
* @return mixed
89+
*/
90+
public function getLoadSheetsOnly();
91+
92+
/**
93+
* Set which sheets to load.
94+
*
95+
* @param mixed $value
96+
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
97+
* If NULL, then it tells the Reader to read all worksheets in the workbook
98+
*
99+
* @return IReader
100+
*/
101+
public function setLoadSheetsOnly($value);
102+
103+
/**
104+
* Set all sheets to load
105+
* Tells the Reader to load all worksheets from the workbook.
106+
*
107+
* @return IReader
108+
*/
109+
public function setLoadAllSheets();
110+
111+
/**
112+
* Read filter.
113+
*
114+
* @return IReadFilter
115+
*/
116+
public function getReadFilter();
117+
118+
/**
119+
* Set read filter.
120+
*
121+
* @param IReadFilter $pValue
122+
*
123+
* @return IReader
124+
*/
125+
public function setReadFilter(IReadFilter $pValue);
126+
21127
/**
22128
* Loads PhpSpreadsheet from file.
23129
*

0 commit comments

Comments
 (0)