Slk extends BaseReader
Table of Contents
- COLOR_ARRAY = [ 'FF00FFFF', // 0 - cyan 'FF000000', // 1 - black 'FFFFFFFF', // 2 - white 'FFFF0000', // 3 - red 'FF00FF00', // 4 - green 'FF0000FF', // 5 - blue 'FFFFFF00', // 6 - yellow 'FFFF00FF', ]
- FONT_STYLE_MAPPINGS = ['B' => 'bold', 'I' => 'italic', 'U' => 'underline']
- STYLE_SETTINGS_BORDER = ['B' => 'bottom', 'L' => 'left', 'R' => 'right', 'T' => 'top']
- STYLE_SETTINGS_FONT = ['D' => 'bold', 'I' => 'italic']
- $fileHandle : resource
- $includeCharts : bool
- Read charts that are defined in the workbook? Identifies whether the Reader should read the definitions for any charts that exist in the workbook;.
- $loadSheetsOnly : null|array<string|int, string>
- Restrict which sheets should be loaded? This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
- $readDataOnly : bool
- Read data only? Identifies whether the Reader should only read data values for cells, and ignore any formatting information; or whether it should read both data and formatting.
- $readEmptyCells : bool
- Read empty cells? Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing null value or empty string.
- $readFilter : IReadFilter
- IReadFilter instance.
- $securityScanner : XmlScanner|null
- $fontcount : int
- Font Count.
- $fonts : array<string|int, mixed>
- Fonts.
- $format : int
- Format Count.
- $formats : array<string|int, mixed>
- Formats.
- $inputEncoding : string
- Input encoding.
- $sheetIndex : int
- Sheet index to read.
- __construct() : mixed
- Create a new SYLK Reader instance.
- canRead() : bool
- Validate that the current file is a SYLK file.
- getIncludeCharts() : bool
- Read charts in workbook? If this is true, then the Reader will include any charts that exist in the workbook.
- getInputEncoding() : string
- Get input encoding.
- getLoadSheetsOnly() : mixed
- 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.
- getReadDataOnly() : bool
- Read data only? If this is true, then the Reader will only read data values for cells, it will not read any formatting or structural information (like merges).
- getReadEmptyCells() : bool
- Read empty cells? If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
- getReadFilter() : IReadFilter
- Read filter.
- getSecurityScanner() : XmlScanner|null
- getSecurityScannerOrThrow() : XmlScanner
- getSheetIndex() : int
- Get sheet index.
- listWorksheetInfo() : array<string|int, mixed>
- Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
- load() : Spreadsheet
- Loads Spreadsheet from file.
- loadIntoExisting() : Spreadsheet
- Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
- setIncludeCharts() : IReader
- Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook.
- setInputEncoding() : $this
- Set input encoding.
- setLoadAllSheets() : IReader
- Set all sheets to load Tells the Reader to load all worksheets from the workbook.
- setLoadSheetsOnly() : IReader
- Set which sheets to load.
- setReadDataOnly() : IReader
- Set read data only Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting or structural information (like merges).
- setReadEmptyCells() : IReader
- Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
- setReadFilter() : IReader
- Set read filter.
- setSheetIndex() : $this
- Set sheet index.
- loadSpreadsheetFromFile() : Spreadsheet
- Loads PhpSpreadsheet from file.
- openFile() : void
- Open file for reading.
- processFlags() : void
- addFonts() : void
- addFormats() : void
- addStyle() : void
- addWidth() : void
- canReadOrBust() : void
- columnRowFromRowData() : void
- processCFinal() : void
- processCRecord() : void
- processFormula() : void
- processFRecord() : void
- processPColors() : void
- processPFinal() : void
- processPFontStyles() : void
- processPRecord() : void
- styleSettings() : void
Constants
COLOR_ARRAY
private
mixed
COLOR_ARRAY
= [
'FF00FFFF',
// 0 - cyan
'FF000000',
// 1 - black
'FFFFFFFF',
// 2 - white
'FFFF0000',
// 3 - red
'FF00FF00',
// 4 - green
'FF0000FF',
// 5 - blue
'FFFFFF00',
// 6 - yellow
'FFFF00FF',
]
FONT_STYLE_MAPPINGS
private
mixed
FONT_STYLE_MAPPINGS
= ['B' => 'bold', 'I' => 'italic', 'U' => 'underline']
STYLE_SETTINGS_BORDER
private
mixed
STYLE_SETTINGS_BORDER
= ['B' => 'bottom', 'L' => 'left', 'R' => 'right', 'T' => 'top']
STYLE_SETTINGS_FONT
private
mixed
STYLE_SETTINGS_FONT
= ['D' => 'bold', 'I' => 'italic']
Properties
$fileHandle
protected
resource
$fileHandle
$includeCharts
Read charts that are defined in the workbook? Identifies whether the Reader should read the definitions for any charts that exist in the workbook;.
protected
bool
$includeCharts
= false
$loadSheetsOnly
Restrict which sheets should be loaded? This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
protected
null|array<string|int, string>
$loadSheetsOnly
$readDataOnly
Read data only? Identifies whether the Reader should only read data values for cells, and ignore any formatting information; or whether it should read both data and formatting.
protected
bool
$readDataOnly
= false
$readEmptyCells
Read empty cells? Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing null value or empty string.
protected
bool
$readEmptyCells
= true
$readFilter
IReadFilter instance.
protected
IReadFilter
$readFilter
$securityScanner
protected
XmlScanner|null
$securityScanner
$fontcount
Font Count.
private
int
$fontcount
= 0
$fonts
Fonts.
private
array<string|int, mixed>
$fonts
= []
$format
Format Count.
private
int
$format
= 0
$formats
Formats.
private
array<string|int, mixed>
$formats
= []
$inputEncoding
Input encoding.
private
string
$inputEncoding
= 'ANSI'
$sheetIndex
Sheet index to read.
private
int
$sheetIndex
= 0
Methods
__construct()
Create a new SYLK Reader instance.
public
__construct() : mixed
Return values
mixed —canRead()
Validate that the current file is a SYLK file.
public
canRead(string $filename) : bool
Parameters
- $filename : string
Return values
bool —getIncludeCharts()
Read charts in workbook? If this is true, then the Reader will include any charts that exist in the workbook.
public
getIncludeCharts() : bool
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 values
bool —getInputEncoding()
Get input encoding.
public
getInputEncoding() : string
Tags
Return values
string —getLoadSheetsOnly()
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.
public
getLoadSheetsOnly() : mixed
Return values
mixed —getReadDataOnly()
Read data only? If this is true, then the Reader will only read data values for cells, it will not read any formatting or structural information (like merges).
public
getReadDataOnly() : bool
If false (the default) it will read data and formatting.
Return values
bool —getReadEmptyCells()
Read empty cells? If this is true (the default), then the Reader will read data values for all cells, irrespective of value.
public
getReadEmptyCells() : bool
If false it will not read data for cells containing a null value or an empty string.
Return values
bool —getReadFilter()
Read filter.
public
getReadFilter() : IReadFilter
Return values
IReadFilter —getSecurityScanner()
public
getSecurityScanner() : XmlScanner|null
Return values
XmlScanner|null —getSecurityScannerOrThrow()
public
getSecurityScannerOrThrow() : XmlScanner
Return values
XmlScanner —getSheetIndex()
Get sheet index.
public
getSheetIndex() : int
Return values
int —listWorksheetInfo()
Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
public
listWorksheetInfo(string $filename) : array<string|int, mixed>
Parameters
- $filename : string
Return values
array<string|int, mixed> —load()
Loads Spreadsheet from file.
public
load(string $filename, int $flags) : Spreadsheet
Parameters
- $filename : string
-
The name of the file to load
- $flags : int
-
the optional second parameter flags may be used to identify specific elements that should be loaded, but which won't be loaded by default, using these values: IReader::LOAD_WITH_CHARTS - Include any charts that are defined in the loaded file
Return values
Spreadsheet —loadIntoExisting()
Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
public
loadIntoExisting(string $filename, Spreadsheet $spreadsheet) : Spreadsheet
Parameters
- $filename : string
- $spreadsheet : Spreadsheet
Return values
Spreadsheet —setIncludeCharts()
Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook.
public
setIncludeCharts(mixed $includeCharts) : 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.
Parameters
- $includeCharts : mixed
Return values
IReader —setInputEncoding()
Set input encoding.
public
setInputEncoding(string $inputEncoding) : $this
Parameters
- $inputEncoding : string
-
Input encoding, eg: 'ANSI'
Tags
Return values
$this —setLoadAllSheets()
Set all sheets to load Tells the Reader to load all worksheets from the workbook.
public
setLoadAllSheets() : IReader
Return values
IReader —setLoadSheetsOnly()
Set which sheets to load.
public
setLoadSheetsOnly(mixed $sheetList) : IReader
Parameters
- $sheetList : mixed
Return values
IReader —setReadDataOnly()
Set read data only Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting or structural information (like merges).
public
setReadDataOnly(mixed $readCellValuesOnly) : IReader
Set to false (the default) to advise the Reader to read both data and formatting for cells.
Parameters
- $readCellValuesOnly : mixed
Return values
IReader —setReadEmptyCells()
Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value.
public
setReadEmptyCells(mixed $readEmptyCells) : IReader
Set to false to advise the Reader to ignore cells containing a null value or an empty string.
Parameters
- $readEmptyCells : mixed
Return values
IReader —setReadFilter()
Set read filter.
public
setReadFilter(IReadFilter $readFilter) : IReader
Parameters
- $readFilter : IReadFilter
Return values
IReader —setSheetIndex()
Set sheet index.
public
setSheetIndex(int $sheetIndex) : $this
Parameters
- $sheetIndex : int
-
Sheet index
Return values
$this —loadSpreadsheetFromFile()
Loads PhpSpreadsheet from file.
protected
loadSpreadsheetFromFile(string $filename) : Spreadsheet
Parameters
- $filename : string
Return values
Spreadsheet —openFile()
Open file for reading.
protected
openFile(string $filename) : void
Parameters
- $filename : string
Return values
void —processFlags()
protected
processFlags(int $flags) : void
Parameters
- $flags : int
Return values
void —addFonts()
private
addFonts(Spreadsheet &$spreadsheet, string $fontStyle, string $row, string $column) : void
Parameters
- $spreadsheet : Spreadsheet
- $fontStyle : string
- $row : string
- $column : string
Return values
void —addFormats()
private
addFormats(Spreadsheet &$spreadsheet, string $formatStyle, string $row, string $column) : void
Parameters
- $spreadsheet : Spreadsheet
- $formatStyle : string
- $row : string
- $column : string
Return values
void —addStyle()
private
addStyle(Spreadsheet &$spreadsheet, array<string|int, mixed> $styleData, string $row, string $column) : void
Parameters
- $spreadsheet : Spreadsheet
- $styleData : array<string|int, mixed>
- $row : string
- $column : string
Return values
void —addWidth()
private
addWidth(Spreadsheet $spreadsheet, string $columnWidth, string $startCol, string $endCol) : void
Parameters
- $spreadsheet : Spreadsheet
- $columnWidth : string
- $startCol : string
- $endCol : string
Return values
void —canReadOrBust()
private
canReadOrBust(string $filename) : void
Parameters
- $filename : string
Return values
void —columnRowFromRowData()
private
columnRowFromRowData(array<string|int, mixed> $rowData, string &$column, string &$row) : void
Parameters
- $rowData : array<string|int, mixed>
- $column : string
- $row : string
Return values
void —processCFinal()
private
processCFinal(Spreadsheet &$spreadsheet, bool $hasCalculatedValue, string $cellDataFormula, string $cellData, string $coordinate) : void
Parameters
- $spreadsheet : Spreadsheet
- $hasCalculatedValue : bool
- $cellDataFormula : string
- $cellData : string
- $coordinate : string
Return values
void —processCRecord()
private
processCRecord(array<string|int, mixed> $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column) : void
Parameters
- $rowData : array<string|int, mixed>
- $spreadsheet : Spreadsheet
- $row : string
- $column : string
Return values
void —processFormula()
private
processFormula(string $rowDatum, bool &$hasCalculatedValue, string &$cellDataFormula, string $row, string $column) : void
Parameters
- $rowDatum : string
- $hasCalculatedValue : bool
- $cellDataFormula : string
- $row : string
- $column : string
Return values
void —processFRecord()
private
processFRecord(array<string|int, mixed> $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column) : void
Parameters
- $rowData : array<string|int, mixed>
- $spreadsheet : Spreadsheet
- $row : string
- $column : string
Return values
void —processPColors()
private
processPColors(string $rowDatum, array<string|int, mixed> &$formatArray) : void
Parameters
- $rowDatum : string
- $formatArray : array<string|int, mixed>
Return values
void —processPFinal()
private
processPFinal(Spreadsheet &$spreadsheet, array<string|int, mixed> $formatArray) : void
Parameters
- $spreadsheet : Spreadsheet
- $formatArray : array<string|int, mixed>
Return values
void —processPFontStyles()
private
processPFontStyles(string $rowDatum, array<string|int, mixed> &$formatArray) : void
Parameters
- $rowDatum : string
- $formatArray : array<string|int, mixed>
Return values
void —processPRecord()
private
processPRecord(array<string|int, mixed> $rowData, Spreadsheet &$spreadsheet) : void
Parameters
- $rowData : array<string|int, mixed>
- $spreadsheet : Spreadsheet
Return values
void —styleSettings()
private
styleSettings(string $rowDatum, array<string|int, mixed> &$styleData, string &$fontStyle) : void
Parameters
- $rowDatum : string
- $styleData : array<string|int, mixed>
- $fontStyle : string