Minor improvements (#1028)
* Initial tweaks * Move signatures for abstract BaseReader methods to the IReader interface * Appease the great whitespace gods
This commit is contained in:
parent
ca56fd258c
commit
2adaad3b01
|
@ -39,7 +39,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.0",
|
"php": "5.6|^7.0",
|
||||||
"ext-ctype": "*",
|
"ext-ctype": "*",
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
|
|
|
@ -56,7 +56,7 @@ foreach ($customProperties as $customProperty) {
|
||||||
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
|
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
|
||||||
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
|
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
|
||||||
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
|
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
|
||||||
$formattedValue = date('d-M-Y H:i:s', $propertyValue);
|
$formattedValue = date('d-M-Y H:i:s', (int) $propertyValue);
|
||||||
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
|
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||||
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
|
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -56,7 +56,7 @@ foreach ($customProperties as $customProperty) {
|
||||||
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
|
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
|
||||||
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
|
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
|
||||||
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
|
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
|
||||||
$formattedValue = date('d-M-Y H:i:s', $propertyValue);
|
$formattedValue = date('d-M-Y H:i:s', (int) $propertyValue);
|
||||||
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
|
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||||
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
|
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,7 +30,7 @@ for ($col = 1; $col <= 50; ++$col) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$d = microtime(true) - $t;
|
$d = microtime(true) - $t;
|
||||||
$helper->log('Add data (end) . time: ' . round($d . 2) . ' s');
|
$helper->log('Add data (end) . time: ' . round((string) ($d . 2)) . ' s');
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
$helper->write($spreadsheet, __FILE__);
|
$helper->write($spreadsheet, __FILE__);
|
||||||
|
|
|
@ -60,27 +60,11 @@ abstract class BaseReader implements IReader
|
||||||
$this->readFilter = new DefaultReadFilter();
|
$this->readFilter = new DefaultReadFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read data only?
|
|
||||||
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
|
|
||||||
* If false (the default) it will read data and formatting.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getReadDataOnly()
|
public function getReadDataOnly()
|
||||||
{
|
{
|
||||||
return $this->readDataOnly;
|
return $this->readDataOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set read data only
|
|
||||||
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
|
|
||||||
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
|
||||||
*
|
|
||||||
* @param bool $pValue
|
|
||||||
*
|
|
||||||
* @return IReader
|
|
||||||
*/
|
|
||||||
public function setReadDataOnly($pValue)
|
public function setReadDataOnly($pValue)
|
||||||
{
|
{
|
||||||
$this->readDataOnly = (bool) $pValue;
|
$this->readDataOnly = (bool) $pValue;
|
||||||
|
@ -88,27 +72,11 @@ abstract class BaseReader implements IReader
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read empty cells?
|
|
||||||
* If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
|
|
||||||
* If false it will not read data for cells containing a null value or an empty string.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getReadEmptyCells()
|
public function getReadEmptyCells()
|
||||||
{
|
{
|
||||||
return $this->readEmptyCells;
|
return $this->readEmptyCells;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set read empty cells
|
|
||||||
* Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
|
|
||||||
* Set to false to advise the Reader to ignore cells containing a null value or an empty string.
|
|
||||||
*
|
|
||||||
* @param bool $pValue
|
|
||||||
*
|
|
||||||
* @return IReader
|
|
||||||
*/
|
|
||||||
public function setReadEmptyCells($pValue)
|
public function setReadEmptyCells($pValue)
|
||||||
{
|
{
|
||||||
$this->readEmptyCells = (bool) $pValue;
|
$this->readEmptyCells = (bool) $pValue;
|
||||||
|
@ -116,29 +84,11 @@ abstract class BaseReader implements IReader
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read charts in workbook?
|
|
||||||
* If this is true, then the Reader will include any charts that exist in the workbook.
|
|
||||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
|
||||||
* If false (the default) it will ignore any charts defined in the workbook file.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getIncludeCharts()
|
public function getIncludeCharts()
|
||||||
{
|
{
|
||||||
return $this->includeCharts;
|
return $this->includeCharts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set read charts in workbook
|
|
||||||
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
|
||||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
|
||||||
* Set to false (the default) to discard charts.
|
|
||||||
*
|
|
||||||
* @param bool $pValue
|
|
||||||
*
|
|
||||||
* @return IReader
|
|
||||||
*/
|
|
||||||
public function setIncludeCharts($pValue)
|
public function setIncludeCharts($pValue)
|
||||||
{
|
{
|
||||||
$this->includeCharts = (bool) $pValue;
|
$this->includeCharts = (bool) $pValue;
|
||||||
|
@ -146,27 +96,11 @@ abstract class BaseReader implements IReader
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get which sheets to load
|
|
||||||
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
|
|
||||||
* indicating that all worksheets in the workbook should be loaded.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getLoadSheetsOnly()
|
public function getLoadSheetsOnly()
|
||||||
{
|
{
|
||||||
return $this->loadSheetsOnly;
|
return $this->loadSheetsOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set which sheets to load.
|
|
||||||
*
|
|
||||||
* @param mixed $value
|
|
||||||
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
|
|
||||||
* If NULL, then it tells the Reader to read all worksheets in the workbook
|
|
||||||
*
|
|
||||||
* @return IReader
|
|
||||||
*/
|
|
||||||
public function setLoadSheetsOnly($value)
|
public function setLoadSheetsOnly($value)
|
||||||
{
|
{
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
|
@ -178,12 +112,6 @@ abstract class BaseReader implements IReader
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set all sheets to load
|
|
||||||
* Tells the Reader to load all worksheets from the workbook.
|
|
||||||
*
|
|
||||||
* @return IReader
|
|
||||||
*/
|
|
||||||
public function setLoadAllSheets()
|
public function setLoadAllSheets()
|
||||||
{
|
{
|
||||||
$this->loadSheetsOnly = null;
|
$this->loadSheetsOnly = null;
|
||||||
|
@ -191,23 +119,11 @@ abstract class BaseReader implements IReader
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read filter.
|
|
||||||
*
|
|
||||||
* @return IReadFilter
|
|
||||||
*/
|
|
||||||
public function getReadFilter()
|
public function getReadFilter()
|
||||||
{
|
{
|
||||||
return $this->readFilter;
|
return $this->readFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set read filter.
|
|
||||||
*
|
|
||||||
* @param IReadFilter $pValue
|
|
||||||
*
|
|
||||||
* @return IReader
|
|
||||||
*/
|
|
||||||
public function setReadFilter(IReadFilter $pValue)
|
public function setReadFilter(IReadFilter $pValue)
|
||||||
{
|
{
|
||||||
$this->readFilter = $pValue;
|
$this->readFilter = $pValue;
|
||||||
|
|
|
@ -18,6 +18,112 @@ interface IReader
|
||||||
*/
|
*/
|
||||||
public function canRead($pFilename);
|
public function canRead($pFilename);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read data only?
|
||||||
|
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
|
||||||
|
* If false (the default) it will read data and formatting.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getReadDataOnly();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set read data only
|
||||||
|
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
|
||||||
|
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
||||||
|
*
|
||||||
|
* @param bool $pValue
|
||||||
|
*
|
||||||
|
* @return IReader
|
||||||
|
*/
|
||||||
|
public function setReadDataOnly($pValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read empty cells?
|
||||||
|
* If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
|
||||||
|
* If false it will not read data for cells containing a null value or an empty string.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getReadEmptyCells();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set read empty cells
|
||||||
|
* Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
|
||||||
|
* Set to false to advise the Reader to ignore cells containing a null value or an empty string.
|
||||||
|
*
|
||||||
|
* @param bool $pValue
|
||||||
|
*
|
||||||
|
* @return IReader
|
||||||
|
*/
|
||||||
|
public function setReadEmptyCells($pValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read charts in workbook?
|
||||||
|
* If this is true, then the Reader will include any charts that exist in the workbook.
|
||||||
|
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||||
|
* If false (the default) it will ignore any charts defined in the workbook file.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getIncludeCharts();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set read charts in workbook
|
||||||
|
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
||||||
|
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||||
|
* Set to false (the default) to discard charts.
|
||||||
|
*
|
||||||
|
* @param bool $pValue
|
||||||
|
*
|
||||||
|
* @return IReader
|
||||||
|
*/
|
||||||
|
public function setIncludeCharts($pValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get which sheets to load
|
||||||
|
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
|
||||||
|
* indicating that all worksheets in the workbook should be loaded.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLoadSheetsOnly();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set which sheets to load.
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
|
||||||
|
* If NULL, then it tells the Reader to read all worksheets in the workbook
|
||||||
|
*
|
||||||
|
* @return IReader
|
||||||
|
*/
|
||||||
|
public function setLoadSheetsOnly($value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set all sheets to load
|
||||||
|
* Tells the Reader to load all worksheets from the workbook.
|
||||||
|
*
|
||||||
|
* @return IReader
|
||||||
|
*/
|
||||||
|
public function setLoadAllSheets();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read filter.
|
||||||
|
*
|
||||||
|
* @return IReadFilter
|
||||||
|
*/
|
||||||
|
public function getReadFilter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set read filter.
|
||||||
|
*
|
||||||
|
* @param IReadFilter $pValue
|
||||||
|
*
|
||||||
|
* @return IReader
|
||||||
|
*/
|
||||||
|
public function setReadFilter(IReadFilter $pValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PhpSpreadsheet from file.
|
* Loads PhpSpreadsheet from file.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue