Work on renaming method arguments for the Readers and Writers
This commit is contained in:
parent
0acc8ff822
commit
bd0462bcfc
|
|
@ -18,7 +18,7 @@ $helper->logWrite($writer, $filename, $callStartTime);
|
|||
|
||||
class MyReadFilter implements IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
// Read title row and rows 20 - 30
|
||||
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ $sheetname = 'Data Sheet #3';
|
|||
|
||||
class MyReadFilter implements IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
// Read rows 1 to 7 and columns A to E only
|
||||
if ($row >= 1 && $row <= 7) {
|
||||
if (in_array($column, range('A', 'E'))) {
|
||||
if (in_array($columnAddress, range('A', 'E'))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ class MyReadFilter implements IReadFilter
|
|||
$this->columns = $columns;
|
||||
}
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
if ($row >= $this->startRow && $row <= $this->endRow) {
|
||||
if (in_array($column, $this->columns)) {
|
||||
if (in_array($columnAddress, $this->columns)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ChunkReadFilter implements IReadFilter
|
|||
$this->endRow = $startRow + $chunkSize;
|
||||
}
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
// Only read the heading row, and the rows that were configured in the constructor
|
||||
if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ChunkReadFilter implements IReadFilter
|
|||
$this->endRow = $startRow + $chunkSize;
|
||||
}
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
|
||||
if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ChunkReadFilter implements IReadFilter
|
|||
$this->endRow = $startRow + $chunkSize;
|
||||
}
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
|
||||
if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) {
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ abstract class BaseReader implements IReader
|
|||
return $this->readDataOnly;
|
||||
}
|
||||
|
||||
public function setReadDataOnly($pValue)
|
||||
public function setReadDataOnly($readCellValuesOnly)
|
||||
{
|
||||
$this->readDataOnly = (bool) $pValue;
|
||||
$this->readDataOnly = (bool) $readCellValuesOnly;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -78,9 +78,9 @@ abstract class BaseReader implements IReader
|
|||
return $this->readEmptyCells;
|
||||
}
|
||||
|
||||
public function setReadEmptyCells($pValue)
|
||||
public function setReadEmptyCells($readEmptyCells)
|
||||
{
|
||||
$this->readEmptyCells = (bool) $pValue;
|
||||
$this->readEmptyCells = (bool) $readEmptyCells;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -90,9 +90,9 @@ abstract class BaseReader implements IReader
|
|||
return $this->includeCharts;
|
||||
}
|
||||
|
||||
public function setIncludeCharts($pValue)
|
||||
public function setIncludeCharts($includeCharts)
|
||||
{
|
||||
$this->includeCharts = (bool) $pValue;
|
||||
$this->includeCharts = (bool) $includeCharts;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -102,13 +102,13 @@ abstract class BaseReader implements IReader
|
|||
return $this->loadSheetsOnly;
|
||||
}
|
||||
|
||||
public function setLoadSheetsOnly($value)
|
||||
public function setLoadSheetsOnly($sheetList)
|
||||
{
|
||||
if ($value === null) {
|
||||
if ($sheetList === null) {
|
||||
return $this->setLoadAllSheets();
|
||||
}
|
||||
|
||||
$this->loadSheetsOnly = is_array($value) ? $value : [$value];
|
||||
$this->loadSheetsOnly = is_array($sheetList) ? $sheetList : [$sheetList];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -125,9 +125,9 @@ abstract class BaseReader implements IReader
|
|||
return $this->readFilter;
|
||||
}
|
||||
|
||||
public function setReadFilter(IReadFilter $pValue)
|
||||
public function setReadFilter(IReadFilter $readFilter)
|
||||
{
|
||||
$this->readFilter = $pValue;
|
||||
$this->readFilter = $readFilter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -140,22 +140,22 @@ abstract class BaseReader implements IReader
|
|||
/**
|
||||
* Open file for reading.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*/
|
||||
protected function openFile($pFilename): void
|
||||
protected function openFile($filename): void
|
||||
{
|
||||
if ($pFilename) {
|
||||
File::assertFile($pFilename);
|
||||
if ($filename) {
|
||||
File::assertFile($filename);
|
||||
|
||||
// Open file
|
||||
$fileHandle = fopen($pFilename, 'rb');
|
||||
$fileHandle = fopen($filename, 'rb');
|
||||
} else {
|
||||
$fileHandle = false;
|
||||
}
|
||||
if ($fileHandle !== false) {
|
||||
$this->fileHandle = $fileHandle;
|
||||
} else {
|
||||
throw new ReaderException('Could not open file ' . $pFilename . ' for reading.');
|
||||
throw new ReaderException('Could not open file ' . $filename . ' for reading.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ class Csv extends BaseReader
|
|||
/**
|
||||
* Set input encoding.
|
||||
*
|
||||
* @param string $pValue Input encoding, eg: 'UTF-8'
|
||||
* @param string $encoding Input encoding, eg: 'UTF-8'
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputEncoding($pValue)
|
||||
public function setInputEncoding($encoding)
|
||||
{
|
||||
$this->inputEncoding = $pValue;
|
||||
$this->inputEncoding = $encoding;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -240,14 +240,14 @@ class Csv extends BaseReader
|
|||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
public function listWorksheetInfo($filename)
|
||||
{
|
||||
// Open file
|
||||
$this->openFileOrMemory($pFilename);
|
||||
$this->openFileOrMemory($filename);
|
||||
$fileHandle = $this->fileHandle;
|
||||
|
||||
// Skip BOM, if any
|
||||
|
|
@ -280,30 +280,30 @@ class Csv extends BaseReader
|
|||
/**
|
||||
* Loads Spreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
// Create new Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $spreadsheet);
|
||||
return $this->loadIntoExisting($filename, $spreadsheet);
|
||||
}
|
||||
|
||||
private function openFileOrMemory($pFilename): void
|
||||
private function openFileOrMemory($filename): void
|
||||
{
|
||||
// Open file
|
||||
$fhandle = $this->canRead($pFilename);
|
||||
$fhandle = $this->canRead($filename);
|
||||
if (!$fhandle) {
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
throw new Exception($filename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
$this->openFile($pFilename);
|
||||
$this->openFile($filename);
|
||||
if ($this->inputEncoding !== 'UTF-8') {
|
||||
fclose($this->fileHandle);
|
||||
$entireFile = file_get_contents($pFilename);
|
||||
$entireFile = file_get_contents($filename);
|
||||
$this->fileHandle = fopen('php://memory', 'r+b');
|
||||
$data = StringHelper::convertEncoding($entireFile, 'UTF-8', $this->inputEncoding);
|
||||
fwrite($this->fileHandle, $data);
|
||||
|
|
@ -314,17 +314,17 @@ class Csv extends BaseReader
|
|||
/**
|
||||
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
|
||||
public function loadIntoExisting($filename, Spreadsheet $spreadsheet)
|
||||
{
|
||||
$lineEnding = ini_get('auto_detect_line_endings');
|
||||
ini_set('auto_detect_line_endings', true);
|
||||
|
||||
// Open file
|
||||
$this->openFileOrMemory($pFilename);
|
||||
$this->openFileOrMemory($filename);
|
||||
$fileHandle = $this->fileHandle;
|
||||
|
||||
// Skip BOM, if any
|
||||
|
|
@ -437,13 +437,13 @@ class Csv extends BaseReader
|
|||
/**
|
||||
* Set sheet index.
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @param int $indexValue Sheet index
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSheetIndex($pValue)
|
||||
public function setSheetIndex($indexValue)
|
||||
{
|
||||
$this->sheetIndex = $pValue;
|
||||
$this->sheetIndex = $indexValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -499,15 +499,15 @@ class Csv extends BaseReader
|
|||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
// Check if file exists
|
||||
try {
|
||||
$this->openFile($pFilename);
|
||||
$this->openFile($filename);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -515,13 +515,13 @@ class Csv extends BaseReader
|
|||
fclose($this->fileHandle);
|
||||
|
||||
// Trust file extension if any
|
||||
$extension = strtolower(pathinfo($pFilename, PATHINFO_EXTENSION));
|
||||
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
if (in_array($extension, ['csv', 'tsv'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Attempt to guess mimetype
|
||||
$type = mime_content_type($pFilename);
|
||||
$type = mime_content_type($filename);
|
||||
$supportedTypes = [
|
||||
'application/csv',
|
||||
'text/csv',
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ class DefaultReadFilter implements IReadFilter
|
|||
/**
|
||||
* Should this cell be read?
|
||||
*
|
||||
* @param string $column Column address (as a string value like "A", or "IV")
|
||||
* @param string $columnAddress Column address (as a string value like "A", or "IV")
|
||||
* @param int $row Row number
|
||||
* @param string $worksheetName Optional worksheet name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,19 +63,19 @@ class Gnumeric extends BaseReader
|
|||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
File::assertFile($pFilename);
|
||||
File::assertFile($filename);
|
||||
|
||||
// Check if gzlib functions are available
|
||||
$data = '';
|
||||
if (function_exists('gzread')) {
|
||||
// Read signature data (first 3 bytes)
|
||||
$fh = fopen($pFilename, 'rb');
|
||||
$fh = fopen($filename, 'rb');
|
||||
$data = fread($fh, 2);
|
||||
fclose($fh);
|
||||
}
|
||||
|
|
@ -420,18 +420,18 @@ class Gnumeric extends BaseReader
|
|||
/**
|
||||
* Loads Spreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
// Create new Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->removeSheetByIndex(0);
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $spreadsheet);
|
||||
return $this->loadIntoExisting($filename, $spreadsheet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -136,15 +136,15 @@ class Html extends BaseReader
|
|||
/**
|
||||
* Validate that the current file is an HTML file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
// Check if file exists
|
||||
try {
|
||||
$this->openFile($pFilename);
|
||||
$this->openFile($filename);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -204,17 +204,17 @@ class Html extends BaseReader
|
|||
/**
|
||||
* Loads Spreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
// Create new Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $spreadsheet);
|
||||
return $this->loadIntoExisting($filename, $spreadsheet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ interface IReadFilter
|
|||
/**
|
||||
* Should this cell be read?
|
||||
*
|
||||
* @param string $column Column address (as a string value like "A", or "IV")
|
||||
* @param string $columnAddress Column address (as a string value like "A", or "IV")
|
||||
* @param int $row Row number
|
||||
* @param string $worksheetName Optional worksheet name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '');
|
||||
public function readCell($columnAddress, $row, $worksheetName = '');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ interface IReader
|
|||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
public function canRead($filename);
|
||||
|
||||
/**
|
||||
* Read data only?
|
||||
|
|
@ -32,11 +32,11 @@ interface IReader
|
|||
* 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
|
||||
* @param bool $readCellValuesOnly
|
||||
*
|
||||
* @return IReader
|
||||
*/
|
||||
public function setReadDataOnly($pValue);
|
||||
public function setReadDataOnly($readCellValuesOnly);
|
||||
|
||||
/**
|
||||
* Read empty cells?
|
||||
|
|
@ -52,11 +52,11 @@ interface IReader
|
|||
* 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
|
||||
* @param bool $readEmptyCells
|
||||
*
|
||||
* @return IReader
|
||||
*/
|
||||
public function setReadEmptyCells($pValue);
|
||||
public function setReadEmptyCells($readEmptyCells);
|
||||
|
||||
/**
|
||||
* Read charts in workbook?
|
||||
|
|
@ -74,11 +74,11 @@ interface IReader
|
|||
* 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
|
||||
* @param bool $includeCharts
|
||||
*
|
||||
* @return IReader
|
||||
*/
|
||||
public function setIncludeCharts($pValue);
|
||||
public function setIncludeCharts($includeCharts);
|
||||
|
||||
/**
|
||||
* Get which sheets to load
|
||||
|
|
@ -92,13 +92,13 @@ interface IReader
|
|||
/**
|
||||
* Set which sheets to load.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $sheetList
|
||||
* 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($sheetList);
|
||||
|
||||
/**
|
||||
* Set all sheets to load
|
||||
|
|
@ -120,14 +120,14 @@ interface IReader
|
|||
*
|
||||
* @return IReader
|
||||
*/
|
||||
public function setReadFilter(IReadFilter $pValue);
|
||||
public function setReadFilter(IReadFilter $readFilter);
|
||||
|
||||
/**
|
||||
* Loads PhpSpreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
||||
*/
|
||||
public function load($pFilename);
|
||||
public function load($filename);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,20 +40,20 @@ class Ods extends BaseReader
|
|||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
File::assertFile($pFilename);
|
||||
File::assertFile($filename);
|
||||
|
||||
$mimeType = 'UNKNOWN';
|
||||
|
||||
// Load file
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($pFilename) === true) {
|
||||
if ($zip->open($filename) === true) {
|
||||
// check if it is an OOXML archive
|
||||
$stat = $zip->statName('mimetype');
|
||||
if ($stat && ($stat['size'] <= 255)) {
|
||||
|
|
@ -231,17 +231,17 @@ class Ods extends BaseReader
|
|||
/**
|
||||
* Loads PhpSpreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
// Create new Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $spreadsheet);
|
||||
return $this->loadIntoExisting($filename, $spreadsheet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -65,14 +65,14 @@ class Slk extends BaseReader
|
|||
/**
|
||||
* Validate that the current file is a SYLK file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
try {
|
||||
$this->openFile($pFilename);
|
||||
$this->openFile($filename);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -196,17 +196,17 @@ class Slk extends BaseReader
|
|||
/**
|
||||
* Loads PhpSpreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
// Create new Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $spreadsheet);
|
||||
return $this->loadIntoExisting($filename, $spreadsheet);
|
||||
}
|
||||
|
||||
private $colorArray = [
|
||||
|
|
|
|||
|
|
@ -418,20 +418,20 @@ class Xls extends BaseReader
|
|||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
File::assertFile($pFilename);
|
||||
File::assertFile($filename);
|
||||
|
||||
try {
|
||||
// Use ParseXL for the hard work.
|
||||
$ole = new OLERead();
|
||||
|
||||
// get excel data
|
||||
$ole->read($pFilename);
|
||||
$ole->read($filename);
|
||||
|
||||
return true;
|
||||
} catch (PhpSpreadsheetException $e) {
|
||||
|
|
@ -621,14 +621,14 @@ class Xls extends BaseReader
|
|||
/**
|
||||
* Loads PhpSpreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
// Read the OLE file
|
||||
$this->loadOLE($pFilename);
|
||||
$this->loadOLE($filename);
|
||||
|
||||
// Initialisations
|
||||
$this->spreadsheet = new Spreadsheet();
|
||||
|
|
|
|||
|
|
@ -69,18 +69,18 @@ class Xlsx extends BaseReader
|
|||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
File::assertFile($pFilename);
|
||||
File::assertFile($filename);
|
||||
|
||||
$result = false;
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($pFilename) === true) {
|
||||
if ($zip->open($filename) === true) {
|
||||
$workbookBasename = $this->getWorkbookBaseName($zip);
|
||||
$result = !empty($workbookBasename);
|
||||
|
||||
|
|
@ -311,13 +311,13 @@ class Xlsx extends BaseReader
|
|||
/**
|
||||
* Loads Spreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
File::assertFile($pFilename);
|
||||
File::assertFile($filename);
|
||||
|
||||
// Initialisations
|
||||
$excel = new Spreadsheet();
|
||||
|
|
@ -329,7 +329,7 @@ class Xlsx extends BaseReader
|
|||
$unparsedLoadedData = [];
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($pFilename);
|
||||
$zip->open($filename);
|
||||
|
||||
// Read the theme first, because we need the colour scheme when reading the styles
|
||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||
|
|
@ -1036,7 +1036,7 @@ class Xlsx extends BaseReader
|
|||
$hfImages[(string) $shape['id']]->setName((string) $imageData['title']);
|
||||
}
|
||||
|
||||
$hfImages[(string) $shape['id']]->setPath('zip://' . File::realpath($pFilename) . '#' . $drawings[(string) $imageData['relid']], false);
|
||||
$hfImages[(string) $shape['id']]->setPath('zip://' . File::realpath($filename) . '#' . $drawings[(string) $imageData['relid']], false);
|
||||
$hfImages[(string) $shape['id']]->setResizeProportional(false);
|
||||
$hfImages[(string) $shape['id']]->setWidth($style['width']);
|
||||
$hfImages[(string) $shape['id']]->setHeight($style['height']);
|
||||
|
|
@ -1124,7 +1124,7 @@ class Xlsx extends BaseReader
|
|||
$objDrawing->setName((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'name'));
|
||||
$objDrawing->setDescription((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'descr'));
|
||||
$objDrawing->setPath(
|
||||
'zip://' . File::realpath($pFilename) . '#' .
|
||||
'zip://' . File::realpath($filename) . '#' .
|
||||
$images[(string) self::getArrayItem(
|
||||
$blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'),
|
||||
'embed'
|
||||
|
|
@ -1176,7 +1176,7 @@ class Xlsx extends BaseReader
|
|||
$objDrawing->setName((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'name'));
|
||||
$objDrawing->setDescription((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'descr'));
|
||||
$objDrawing->setPath(
|
||||
'zip://' . File::realpath($pFilename) . '#' .
|
||||
'zip://' . File::realpath($filename) . '#' .
|
||||
$images[(string) self::getArrayItem(
|
||||
$blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'),
|
||||
'embed'
|
||||
|
|
|
|||
|
|
@ -96,11 +96,11 @@ class Xml extends BaseReader
|
|||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
public function canRead($filename)
|
||||
{
|
||||
// Office xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
// Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
|
||||
|
|
@ -118,7 +118,7 @@ class Xml extends BaseReader
|
|||
];
|
||||
|
||||
// Open file
|
||||
$data = file_get_contents($pFilename);
|
||||
$data = file_get_contents($filename);
|
||||
|
||||
// Why?
|
||||
//$data = str_replace("'", '"', $data); // fix headers with single quote
|
||||
|
|
@ -272,18 +272,18 @@ class Xml extends BaseReader
|
|||
/**
|
||||
* Loads Spreadsheet from file.
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function load($pFilename)
|
||||
public function load($filename)
|
||||
{
|
||||
// Create new Spreadsheet
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->removeSheetByIndex(0);
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $spreadsheet);
|
||||
return $this->loadIntoExisting($filename, $spreadsheet);
|
||||
}
|
||||
|
||||
private static function identifyFixedStyleValue($styleList, &$styleAttributeValue)
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ abstract class BaseWriter implements IWriter
|
|||
return $this->includeCharts;
|
||||
}
|
||||
|
||||
public function setIncludeCharts($pValue)
|
||||
public function setIncludeCharts($includeCharts)
|
||||
{
|
||||
$this->includeCharts = (bool) $pValue;
|
||||
$this->includeCharts = (bool) $includeCharts;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -62,9 +62,9 @@ abstract class BaseWriter implements IWriter
|
|||
return $this->preCalculateFormulas;
|
||||
}
|
||||
|
||||
public function setPreCalculateFormulas($pValue)
|
||||
public function setPreCalculateFormulas($precalculateFormulas)
|
||||
{
|
||||
$this->preCalculateFormulas = (bool) $pValue;
|
||||
$this->preCalculateFormulas = (bool) $precalculateFormulas;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -74,15 +74,15 @@ abstract class BaseWriter implements IWriter
|
|||
return $this->useDiskCaching;
|
||||
}
|
||||
|
||||
public function setUseDiskCaching($pValue, $pDirectory = null)
|
||||
public function setUseDiskCaching($useDiskCache, $cacheDirectory = null)
|
||||
{
|
||||
$this->useDiskCaching = $pValue;
|
||||
$this->useDiskCaching = $useDiskCache;
|
||||
|
||||
if ($pDirectory !== null) {
|
||||
if (is_dir($pDirectory)) {
|
||||
$this->diskCachingDirectory = $pDirectory;
|
||||
if ($cacheDirectory !== null) {
|
||||
if (is_dir($cacheDirectory)) {
|
||||
$this->diskCachingDirectory = $cacheDirectory;
|
||||
} else {
|
||||
throw new Exception("Directory does not exist: $pDirectory");
|
||||
throw new Exception("Directory does not exist: $cacheDirectory");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@ class Csv extends BaseWriter
|
|||
/**
|
||||
* Save PhpSpreadsheet to file.
|
||||
*
|
||||
* @param resource|string $pFilename
|
||||
* @param resource|string $filename
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
// Fetch sheet
|
||||
$sheet = $this->spreadsheet->getSheet($this->sheetIndex);
|
||||
|
|
@ -90,7 +90,7 @@ class Csv extends BaseWriter
|
|||
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
|
||||
|
||||
// Open file
|
||||
$this->openFileHandle($pFilename);
|
||||
$this->openFileHandle($filename);
|
||||
|
||||
if ($this->excelCompatibility) {
|
||||
$this->setUseBOM(true); // Enforce UTF-8 BOM Header
|
||||
|
|
|
|||
|
|
@ -151,12 +151,12 @@ class Html extends BaseWriter
|
|||
/**
|
||||
* Save Spreadsheet to file.
|
||||
*
|
||||
* @param resource|string $pFilename
|
||||
* @param resource|string $filename
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
// Open file
|
||||
$this->openFileHandle($pFilename);
|
||||
$this->openFileHandle($filename);
|
||||
|
||||
// Write html
|
||||
fwrite($this->fileHandle, $this->generateHTMLAll());
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ interface IWriter
|
|||
{
|
||||
/**
|
||||
* IWriter constructor.
|
||||
*
|
||||
* @param Spreadsheet $spreadsheet The spreadsheet that we want to save using this Writer
|
||||
*/
|
||||
public function __construct(Spreadsheet $spreadsheet);
|
||||
|
||||
|
|
@ -25,11 +27,11 @@ interface IWriter
|
|||
* Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.
|
||||
* Set to false (the default) to ignore charts.
|
||||
*
|
||||
* @param bool $pValue
|
||||
* @param bool $includeCharts
|
||||
*
|
||||
* @return IWriter
|
||||
*/
|
||||
public function setIncludeCharts($pValue);
|
||||
public function setIncludeCharts($includeCharts);
|
||||
|
||||
/**
|
||||
* Get Pre-Calculate Formulas flag
|
||||
|
|
@ -48,18 +50,18 @@ interface IWriter
|
|||
* Set to true (the default) to advise the Writer to calculate all formulae on save
|
||||
* Set to false to prevent precalculation of formulae on save.
|
||||
*
|
||||
* @param bool $pValue Pre-Calculate Formulas?
|
||||
* @param bool $precalculateFormulas Pre-Calculate Formulas?
|
||||
*
|
||||
* @return IWriter
|
||||
*/
|
||||
public function setPreCalculateFormulas($pValue);
|
||||
public function setPreCalculateFormulas($precalculateFormulas);
|
||||
|
||||
/**
|
||||
* Save PhpSpreadsheet to file.
|
||||
*
|
||||
* @param resource|string $pFilename Name of the file to save
|
||||
* @param resource|string $filename Name of the file to save
|
||||
*/
|
||||
public function save($pFilename);
|
||||
public function save($filename);
|
||||
|
||||
/**
|
||||
* Get use disk caching where possible?
|
||||
|
|
@ -71,12 +73,12 @@ interface IWriter
|
|||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param bool $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @param bool $useDiskCache
|
||||
* @param string $cacheDirectory Disk caching directory
|
||||
*
|
||||
* @return IWriter
|
||||
*/
|
||||
public function setUseDiskCaching($pValue, $pDirectory = null);
|
||||
public function setUseDiskCaching($useDiskCache, $cacheDirectory = null);
|
||||
|
||||
/**
|
||||
* Get disk caching directory.
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ class Ods extends BaseWriter
|
|||
/**
|
||||
* Save PhpSpreadsheet to file.
|
||||
*
|
||||
* @param resource|string $pFilename
|
||||
* @param resource|string $filename
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
if (!$this->spreadSheet) {
|
||||
throw new WriterException('PhpSpreadsheet object unassigned.');
|
||||
|
|
@ -84,7 +84,7 @@ class Ods extends BaseWriter
|
|||
// garbage collect
|
||||
$this->spreadSheet->garbageCollect();
|
||||
|
||||
$this->openFileHandle($pFilename);
|
||||
$this->openFileHandle($filename);
|
||||
|
||||
$zip = $this->createZip();
|
||||
|
||||
|
|
|
|||
|
|
@ -165,13 +165,13 @@ abstract class Pdf extends Html
|
|||
/**
|
||||
* Set Paper Size.
|
||||
*
|
||||
* @param string $pValue Paper size see PageSetup::PAPERSIZE_*
|
||||
* @param string $paperSize Paper size see PageSetup::PAPERSIZE_*
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPaperSize($pValue)
|
||||
public function setPaperSize($paperSize)
|
||||
{
|
||||
$this->paperSize = $pValue;
|
||||
$this->paperSize = $paperSize;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -189,13 +189,13 @@ abstract class Pdf extends Html
|
|||
/**
|
||||
* Set Orientation.
|
||||
*
|
||||
* @param string $pValue Page orientation see PageSetup::ORIENTATION_*
|
||||
* @param string $orientation Page orientation see PageSetup::ORIENTATION_*
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setOrientation($pValue)
|
||||
public function setOrientation($orientation)
|
||||
{
|
||||
$this->orientation = $pValue;
|
||||
$this->orientation = $orientation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -213,16 +213,16 @@ abstract class Pdf extends Html
|
|||
/**
|
||||
* Set temporary storage directory.
|
||||
*
|
||||
* @param string $pValue Temporary storage directory
|
||||
* @param string $temporaryDirectory Temporary storage directory
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTempDir($pValue)
|
||||
public function setTempDir($temporaryDirectory)
|
||||
{
|
||||
if (is_dir($pValue)) {
|
||||
$this->tempDir = $pValue;
|
||||
if (is_dir($temporaryDirectory)) {
|
||||
$this->tempDir = $temporaryDirectory;
|
||||
} else {
|
||||
throw new WriterException("Directory does not exist: $pValue");
|
||||
throw new WriterException("Directory does not exist: $temporaryDirectory");
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -231,14 +231,14 @@ abstract class Pdf extends Html
|
|||
/**
|
||||
* Save Spreadsheet to PDF file, pre-save.
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @param string $filename Name of the file to save as
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
protected function prepareForSave($pFilename)
|
||||
protected function prepareForSave($filename)
|
||||
{
|
||||
// Open file
|
||||
$this->openFileHandle($pFilename);
|
||||
$this->openFileHandle($filename);
|
||||
|
||||
return $this->fileHandle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ class Dompdf extends Pdf
|
|||
/**
|
||||
* Save Spreadsheet to file.
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @param string $filename Name of the file to save as
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
$fileHandle = parent::prepareForSave($pFilename);
|
||||
$fileHandle = parent::prepareForSave($filename);
|
||||
|
||||
// Default PDF paper size
|
||||
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ class Mpdf extends Pdf
|
|||
/**
|
||||
* Save Spreadsheet to file.
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @param string $filename Name of the file to save as
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
$fileHandle = parent::prepareForSave($pFilename);
|
||||
$fileHandle = parent::prepareForSave($filename);
|
||||
|
||||
// Default PDF paper size
|
||||
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ class Tcpdf extends Pdf
|
|||
/**
|
||||
* Save Spreadsheet to file.
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @param string $filename Name of the file to save as
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
$fileHandle = parent::prepareForSave($pFilename);
|
||||
$fileHandle = parent::prepareForSave($filename);
|
||||
|
||||
// Default PDF paper size
|
||||
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
||||
|
|
@ -97,7 +97,7 @@ class Tcpdf extends Pdf
|
|||
$pdf->SetCreator($this->spreadsheet->getProperties()->getCreator());
|
||||
|
||||
// Write to file
|
||||
fwrite($fileHandle, $pdf->output($pFilename, 'S'));
|
||||
fwrite($fileHandle, $pdf->output($filename, 'S'));
|
||||
|
||||
parent::restoreStateAfterSave();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ class Xls extends BaseWriter
|
|||
/**
|
||||
* Save Spreadsheet to file.
|
||||
*
|
||||
* @param resource|string $pFilename
|
||||
* @param resource|string $filename
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
// garbage collect
|
||||
$this->spreadsheet->garbageCollect();
|
||||
|
|
@ -218,7 +218,7 @@ class Xls extends BaseWriter
|
|||
|
||||
$root = new Root(time(), time(), $arrRootData);
|
||||
// save the OLE file
|
||||
$this->openFileHandle($pFilename);
|
||||
$this->openFileHandle($filename);
|
||||
$root->save($this->fileHandle);
|
||||
$this->maybeCloseFileHandle();
|
||||
|
||||
|
|
|
|||
|
|
@ -174,15 +174,15 @@ class Xlsx extends BaseWriter
|
|||
/**
|
||||
* Save PhpSpreadsheet to file.
|
||||
*
|
||||
* @param resource|string $pFilename
|
||||
* @param resource|string $filename
|
||||
*/
|
||||
public function save($pFilename): void
|
||||
public function save($filename): void
|
||||
{
|
||||
// garbage collect
|
||||
$this->pathNames = [];
|
||||
$this->spreadSheet->garbageCollect();
|
||||
|
||||
$this->openFileHandle($pFilename);
|
||||
$this->openFileHandle($filename);
|
||||
|
||||
$saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog();
|
||||
Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class CsvContiguousFilter implements IReadFilter
|
|||
return false;
|
||||
}
|
||||
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
if ($this->filterType == 1) {
|
||||
return $this->filter1($row);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
|||
/** Define a Read Filter class implementing IReadFilter */
|
||||
class GnumericFilter implements IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
return $row !== 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
|||
*/
|
||||
class OddColumnReadFilter implements IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
return (\ord(\substr($column, -1, 1)) % 2) === 1;
|
||||
return (\ord(\substr($columnAddress, -1, 1)) % 2) === 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
|||
/** Define a Read Filter class implementing IReadFilter */
|
||||
class XmlFilter implements IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
public function readCell($columnAddress, $row, $worksheetName = '')
|
||||
{
|
||||
return $row !== 4;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue