ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Reader\Slk Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Reader\Slk:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Reader\Slk:

Public Member Functions

 __construct ()
 Create a new SYLK Reader instance. More...
 
 canRead ($pFilename)
 Validate that the current file is a SYLK file. More...
 
 setInputEncoding ($pValue)
 Set input encoding. More...
 
 getInputEncoding ()
 Get input encoding. More...
 
 listWorksheetInfo ($pFilename)
 Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). More...
 
 load ($pFilename)
 Loads PhpSpreadsheet from file. More...
 
 loadIntoExisting ($pFilename, Spreadsheet $spreadsheet)
 Loads PhpSpreadsheet from file into PhpSpreadsheet instance. More...
 
 getSheetIndex ()
 Get sheet index. More...
 
 setSheetIndex ($pValue)
 Set sheet index. More...
 
- Public Member Functions inherited from PhpOffice\PhpSpreadsheet\Reader\BaseReader
 __construct ()
 IReader constructor. More...
 
 getReadDataOnly ()
 Read data only? If this is true, then the Reader will only read data values for cells, it will not read any formatting information. More...
 
 setReadDataOnly ($pValue)
 Set read data only Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. More...
 
 getReadEmptyCells ()
 Read empty cells? If this is true (the default), then the Reader will read data values for all cells, irrespective of value. More...
 
 setReadEmptyCells ($pValue)
 Set read empty cells Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. More...
 
 getIncludeCharts ()
 Read charts in workbook? If this is true, then the Reader will include any charts that exist in the workbook. More...
 
 setIncludeCharts ($pValue)
 Set read charts in workbook Set to true, to advise the Reader to include any charts that exist in the workbook. More...
 
 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. More...
 
 setLoadSheetsOnly ($value)
 Set which sheets to load. More...
 
 setLoadAllSheets ()
 Set all sheets to load Tells the Reader to load all worksheets from the workbook. More...
 
 getReadFilter ()
 Read filter. More...
 
 setReadFilter (IReadFilter $pValue)
 Set read filter. More...
 
 getSecurityScanner ()
 

Private Member Functions

 canReadOrBust (string $pFilename)
 
 processFormula (string $rowDatum, bool &$hasCalculatedValue, string &$cellDataFormula, string $row, string $column)
 
 processCRecord (array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column)
 
 processCFinal (Spreadsheet &$spreadsheet, bool $hasCalculatedValue, string $cellDataFormula, string $cellData, string $coordinate)
 
 processFRecord (array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column)
 
 styleSettings (string $rowDatum, array &$styleData, string &$fontStyle)
 
 addFormats (Spreadsheet &$spreadsheet, string $formatStyle, string $row, string $column)
 
 addFonts (Spreadsheet &$spreadsheet, string $fontStyle, string $row, string $column)
 
 addStyle (Spreadsheet &$spreadsheet, array $styleData, string $row, string $column)
 
 addWidth (Spreadsheet $spreadsheet, string $columnWidth, string $startCol, string $endCol)
 
 processPRecord (array $rowData, Spreadsheet &$spreadsheet)
 
 processPColors (string $rowDatum, array &$formatArray)
 
 processPFontStyles (string $rowDatum, array &$formatArray)
 
 processPFinal (Spreadsheet &$spreadsheet, array $formatArray)
 
 columnRowFromRowData (array $rowData, string &$column, string &$row)
 

Private Attributes

 $inputEncoding = 'ANSI'
 
 $sheetIndex = 0
 
 $formats = []
 
 $format = 0
 
 $fonts = []
 
 $fontcount = 0
 
 $colorArray
 
 $fontStyleMappings
 
 $styleSettingsFont = ['D' => 'bold'
 
 $styleSettingsBorder
 

Additional Inherited Members

- Protected Member Functions inherited from PhpOffice\PhpSpreadsheet\Reader\BaseReader
 openFile ($pFilename)
 Open file for reading. More...
 
- Protected Attributes inherited from PhpOffice\PhpSpreadsheet\Reader\BaseReader
 $readDataOnly = false
 
 $readEmptyCells = true
 
 $includeCharts = false
 
 $loadSheetsOnly
 
 $readFilter
 
 $fileHandle
 
 $securityScanner
 

Detailed Description

Definition at line 14 of file Slk.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Reader\Slk::__construct ( )

Create a new SYLK Reader instance.

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Definition at line 61 of file Slk.php.

62  {
63  parent::__construct();
64  }

Member Function Documentation

◆ addFonts()

PhpOffice\PhpSpreadsheet\Reader\Slk::addFonts ( Spreadsheet $spreadsheet,
string  $fontStyle,
string  $row,
string  $column 
)
private

Definition at line 399 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Spreadsheet\getActiveSheet(), and PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processFRecord().

399  : void
400  {
401  if ($fontStyle && $column > '' && $row > '') {
402  $columnLetter = Coordinate::stringFromColumnIndex((int) $column);
403  if (isset($this->fonts[$fontStyle])) {
404  $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->fonts[$fontStyle]);
405  }
406  }
407  }
$row
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addFormats()

PhpOffice\PhpSpreadsheet\Reader\Slk::addFormats ( Spreadsheet $spreadsheet,
string  $formatStyle,
string  $row,
string  $column 
)
private

Definition at line 389 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Spreadsheet\getActiveSheet(), and PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processFRecord().

389  : void
390  {
391  if ($formatStyle && $column > '' && $row > '') {
392  $columnLetter = Coordinate::stringFromColumnIndex((int) $column);
393  if (isset($this->formats[$formatStyle])) {
394  $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->formats[$formatStyle]);
395  }
396  }
397  }
$row
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addStyle()

PhpOffice\PhpSpreadsheet\Reader\Slk::addStyle ( Spreadsheet $spreadsheet,
array  $styleData,
string  $row,
string  $column 
)
private

Definition at line 409 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Spreadsheet\getActiveSheet(), and PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processFRecord().

409  : void
410  {
411  if ((!empty($styleData)) && $column > '' && $row > '') {
412  $columnLetter = Coordinate::stringFromColumnIndex($column);
413  $spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($styleData);
414  }
415  }
$row
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addWidth()

PhpOffice\PhpSpreadsheet\Reader\Slk::addWidth ( Spreadsheet  $spreadsheet,
string  $columnWidth,
string  $startCol,
string  $endCol 
)
private

Definition at line 417 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Spreadsheet\getActiveSheet(), and PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processFRecord().

417  : void
418  {
419  if ($columnWidth > '') {
420  if ($startCol == $endCol) {
421  $startCol = Coordinate::stringFromColumnIndex((int) $startCol);
422  $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth((float) $columnWidth);
423  } else {
424  $startCol = Coordinate::stringFromColumnIndex($startCol);
425  $endCol = Coordinate::stringFromColumnIndex($endCol);
426  $spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth((float) $columnWidth);
427  do {
428  $spreadsheet->getActiveSheet()->getColumnDimension(++$startCol)->setWidth((float) $columnWidth);
429  } while ($startCol !== $endCol);
430  }
431  }
432  }
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canRead()

PhpOffice\PhpSpreadsheet\Reader\Slk::canRead (   $pFilename)

Validate that the current file is a SYLK file.

Parameters
string$pFilename
Returns
bool

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Definition at line 73 of file Slk.php.

References $data, and PhpOffice\PhpSpreadsheet\Reader\BaseReader\openFile().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\canReadOrBust().

74  {
75  try {
76  $this->openFile($pFilename);
77  } catch (InvalidArgumentException $e) {
78  return false;
79  }
80 
81  // Read sample data (first 2 KB will do)
82  $data = fread($this->fileHandle, 2048);
83 
84  // Count delimiters in file
85  $delimiterCount = substr_count($data, ';');
86  $hasDelimiter = $delimiterCount > 0;
87 
88  // Analyze first line looking for ID; signature
89  $lines = explode("\n", $data);
90  $hasId = substr($lines[0], 0, 4) === 'ID;P';
91 
92  fclose($this->fileHandle);
93 
94  return $hasDelimiter && $hasId;
95  }
openFile($pFilename)
Open file for reading.
Definition: BaseReader.php:145
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canReadOrBust()

PhpOffice\PhpSpreadsheet\Reader\Slk::canReadOrBust ( string  $pFilename)
private

Definition at line 97 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\canRead(), and PhpOffice\PhpSpreadsheet\Reader\BaseReader\openFile().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\listWorksheetInfo(), and PhpOffice\PhpSpreadsheet\Reader\Slk\loadIntoExisting().

97  : void
98  {
99  if (!$this->canRead($pFilename)) {
100  throw new ReaderException($pFilename . ' is an Invalid SYLK file.');
101  }
102  $this->openFile($pFilename);
103  }
canRead($pFilename)
Validate that the current file is a SYLK file.
Definition: Slk.php:73
openFile($pFilename)
Open file for reading.
Definition: BaseReader.php:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ columnRowFromRowData()

PhpOffice\PhpSpreadsheet\Reader\Slk::columnRowFromRowData ( array  $rowData,
string &  $column,
string &  $row 
)
private

Definition at line 556 of file Slk.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\loadIntoExisting().

556  : void
557  {
558  foreach ($rowData as $rowDatum) {
559  $char0 = $rowDatum[0];
560  if ($char0 === 'X' || $char0 == 'C') {
561  $column = substr($rowDatum, 1);
562  } elseif ($char0 === 'Y' || $char0 == 'R') {
563  $row = substr($rowDatum, 1);
564  }
565  }
566  }
$row
+ Here is the caller graph for this function:

◆ getInputEncoding()

PhpOffice\PhpSpreadsheet\Reader\Slk::getInputEncoding ( )

Get input encoding.

Deprecated:
no use is made of this property
Returns
string

Definition at line 132 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\$inputEncoding.

133  {
134  return $this->inputEncoding;
135  }

◆ getSheetIndex()

PhpOffice\PhpSpreadsheet\Reader\Slk::getSheetIndex ( )

Get sheet index.

Returns
int

Definition at line 573 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\$sheetIndex.

574  {
575  return $this->sheetIndex;
576  }

◆ listWorksheetInfo()

PhpOffice\PhpSpreadsheet\Reader\Slk::listWorksheetInfo (   $pFilename)

Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).

Parameters
string$pFilename
Returns
array

Definition at line 144 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\BaseReader\$fileHandle, PhpOffice\PhpSpreadsheet\Reader\Slk\canReadOrBust(), PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex(), and PhpOffice\PhpSpreadsheet\Shared\StringHelper\SYLKtoUTF8().

145  {
146  // Open file
147  $this->canReadOrBust($pFilename);
149  rewind($fileHandle);
150 
151  $worksheetInfo = [];
152  $worksheetInfo[0]['worksheetName'] = basename($pFilename, '.slk');
153 
154  // loop through one row (line) at a time in the file
155  $rowIndex = 0;
156  $columnIndex = 0;
157  while (($rowData = fgets($fileHandle)) !== false) {
158  $columnIndex = 0;
159 
160  // convert SYLK encoded $rowData to UTF-8
161  $rowData = StringHelper::SYLKtoUTF8($rowData);
162 
163  // explode each row at semicolons while taking into account that literal semicolon (;)
164  // is escaped like this (;;)
165  $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
166 
167  $dataType = array_shift($rowData);
168  if ($dataType == 'B') {
169  foreach ($rowData as $rowDatum) {
170  switch ($rowDatum[0]) {
171  case 'X':
172  $columnIndex = (int) substr($rowDatum, 1) - 1;
173 
174  break;
175  case 'Y':
176  $rowIndex = substr($rowDatum, 1);
177 
178  break;
179  }
180  }
181 
182  break;
183  }
184  }
185 
186  $worksheetInfo[0]['lastColumnIndex'] = $columnIndex;
187  $worksheetInfo[0]['totalRows'] = $rowIndex;
188  $worksheetInfo[0]['lastColumnLetter'] = Coordinate::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex'] + 1);
189  $worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
190 
191  // Close file
192  fclose($fileHandle);
193 
194  return $worksheetInfo;
195  }
static SYLKtoUTF8($pValue)
Convert SYLK encoded string to UTF-8.
canReadOrBust(string $pFilename)
Definition: Slk.php:97
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
+ Here is the call graph for this function:

◆ load()

PhpOffice\PhpSpreadsheet\Reader\Slk::load (   $pFilename)

Loads PhpSpreadsheet from file.

Parameters
string$pFilename
Returns
Spreadsheet

Implements PhpOffice\PhpSpreadsheet\Reader\IReader.

Definition at line 204 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\loadIntoExisting().

205  {
206  // Create new Spreadsheet
207  $spreadsheet = new Spreadsheet();
208 
209  // Load into this instance
210  return $this->loadIntoExisting($pFilename, $spreadsheet);
211  }
loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
Definition: Slk.php:508
+ Here is the call graph for this function:

◆ loadIntoExisting()

PhpOffice\PhpSpreadsheet\Reader\Slk::loadIntoExisting (   $pFilename,
Spreadsheet  $spreadsheet 
)

Loads PhpSpreadsheet from file into PhpSpreadsheet instance.

Parameters
string$pFilename
Returns
Spreadsheet

Definition at line 508 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\BaseReader\$fileHandle, $row, PhpOffice\PhpSpreadsheet\Reader\Slk\$sheetIndex, PhpOffice\PhpSpreadsheet\Reader\Slk\canReadOrBust(), PhpOffice\PhpSpreadsheet\Reader\Slk\columnRowFromRowData(), PhpOffice\PhpSpreadsheet\Spreadsheet\createSheet(), PhpOffice\PhpSpreadsheet\Spreadsheet\getActiveSheet(), PhpOffice\PhpSpreadsheet\Spreadsheet\getSheetCount(), PhpOffice\PhpSpreadsheet\Reader\Slk\processCRecord(), PhpOffice\PhpSpreadsheet\Reader\Slk\processFRecord(), PhpOffice\PhpSpreadsheet\Reader\Slk\processPRecord(), PhpOffice\PhpSpreadsheet\Spreadsheet\setActiveSheetIndex(), PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\SHEET_TITLE_MAXIMUM_LENGTH, and PhpOffice\PhpSpreadsheet\Shared\StringHelper\SYLKtoUTF8().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\load().

509  {
510  // Open file
511  $this->canReadOrBust($pFilename);
513  rewind($fileHandle);
514 
515  // Create new Worksheets
516  while ($spreadsheet->getSheetCount() <= $this->sheetIndex) {
517  $spreadsheet->createSheet();
518  }
519  $spreadsheet->setActiveSheetIndex($this->sheetIndex);
520  $spreadsheet->getActiveSheet()->setTitle(substr(basename($pFilename, '.slk'), 0, Worksheet::SHEET_TITLE_MAXIMUM_LENGTH));
521 
522  // Loop through file
523  $column = $row = '';
524 
525  // loop through one row (line) at a time in the file
526  while (($rowDataTxt = fgets($fileHandle)) !== false) {
527  // convert SYLK encoded $rowData to UTF-8
528  $rowDataTxt = StringHelper::SYLKtoUTF8($rowDataTxt);
529 
530  // explode each row at semicolons while taking into account that literal semicolon (;)
531  // is escaped like this (;;)
532  $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowDataTxt)))));
533 
534  $dataType = array_shift($rowData);
535  if ($dataType == 'P') {
536  // Read shared styles
537  $this->processPRecord($rowData, $spreadsheet);
538  } elseif ($dataType == 'C') {
539  // Read cell value data
540  $this->processCRecord($rowData, $spreadsheet, $row, $column);
541  } elseif ($dataType == 'F') {
542  // Read cell formatting
543  $this->processFRecord($rowData, $spreadsheet, $row, $column);
544  } else {
545  $this->columnRowFromRowData($rowData, $column, $row);
546  }
547  }
548 
549  // Close file
550  fclose($fileHandle);
551 
552  // Return
553  return $spreadsheet;
554  }
static SYLKtoUTF8($pValue)
Convert SYLK encoded string to UTF-8.
canReadOrBust(string $pFilename)
Definition: Slk.php:97
processCRecord(array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column)
Definition: Slk.php:277
columnRowFromRowData(array $rowData, string &$column, string &$row)
Definition: Slk.php:556
$row
processFRecord(array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column)
Definition: Slk.php:321
processPRecord(array $rowData, Spreadsheet &$spreadsheet)
Definition: Slk.php:434
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processCFinal()

PhpOffice\PhpSpreadsheet\Reader\Slk::processCFinal ( Spreadsheet $spreadsheet,
bool  $hasCalculatedValue,
string  $cellDataFormula,
string  $cellData,
string  $coordinate 
)
private

Definition at line 311 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Spreadsheet\getActiveSheet(), and PhpOffice\PhpSpreadsheet\Calculation\Calculation\unwrapResult().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processCRecord().

311  : void
312  {
313  // Set cell value
314  $spreadsheet->getActiveSheet()->getCell($coordinate)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
315  if ($hasCalculatedValue) {
316  $cellData = Calculation::unwrapResult($cellData);
317  $spreadsheet->getActiveSheet()->getCell($coordinate)->setCalculatedValue($cellData);
318  }
319  }
static unwrapResult($value)
Remove quotes used as a wrapper to identify string values.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processCRecord()

PhpOffice\PhpSpreadsheet\Reader\Slk::processCRecord ( array  $rowData,
Spreadsheet $spreadsheet,
string &  $row,
string &  $column 
)
private

Definition at line 277 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\processCFinal(), PhpOffice\PhpSpreadsheet\Reader\Slk\processFormula(), PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex(), and PhpOffice\PhpSpreadsheet\Calculation\Calculation\unwrapResult().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\loadIntoExisting().

277  : void
278  {
279  // Read cell value data
280  $hasCalculatedValue = false;
281  $cellDataFormula = $cellData = '';
282  foreach ($rowData as $rowDatum) {
283  switch ($rowDatum[0]) {
284  case 'C':
285  case 'X':
286  $column = substr($rowDatum, 1);
287 
288  break;
289  case 'R':
290  case 'Y':
291  $row = substr($rowDatum, 1);
292 
293  break;
294  case 'K':
295  $cellData = substr($rowDatum, 1);
296 
297  break;
298  case 'E':
299  $this->processFormula($rowDatum, $hasCalculatedValue, $cellDataFormula, $row, $column);
300 
301  break;
302  }
303  }
304  $columnLetter = Coordinate::stringFromColumnIndex((int) $column);
305  $cellData = Calculation::unwrapResult($cellData);
306 
307  // Set cell value
308  $this->processCFinal($spreadsheet, $hasCalculatedValue, $cellDataFormula, $cellData, "$columnLetter$row");
309  }
processCFinal(Spreadsheet &$spreadsheet, bool $hasCalculatedValue, string $cellDataFormula, string $cellData, string $coordinate)
Definition: Slk.php:311
static unwrapResult($value)
Remove quotes used as a wrapper to identify string values.
$row
processFormula(string $rowDatum, bool &$hasCalculatedValue, string &$cellDataFormula, string $row, string $column)
Definition: Slk.php:230
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processFormula()

PhpOffice\PhpSpreadsheet\Reader\Slk::processFormula ( string  $rowDatum,
bool &  $hasCalculatedValue,
string &  $cellDataFormula,
string  $row,
string  $column 
)
private

Definition at line 230 of file Slk.php.

References $key, $row, and PhpOffice\PhpSpreadsheet\Cell\Coordinate\stringFromColumnIndex().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processCRecord().

230  : void
231  {
232  $cellDataFormula = '=' . substr($rowDatum, 1);
233  // Convert R1C1 style references to A1 style references (but only when not quoted)
234  $temp = explode('"', $cellDataFormula);
235  $key = false;
236  foreach ($temp as &$value) {
237  // Only count/replace in alternate array entries
238  if ($key = !$key) {
239  preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE);
240  // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
241  // through the formula from left to right. Reversing means that we work right to left.through
242  // the formula
243  $cellReferences = array_reverse($cellReferences);
244  // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
245  // then modify the formula to use that new reference
246  foreach ($cellReferences as $cellReference) {
247  $rowReference = $cellReference[2][0];
248  // Empty R reference is the current row
249  if ($rowReference == '') {
250  $rowReference = $row;
251  }
252  // Bracketed R references are relative to the current row
253  if ($rowReference[0] == '[') {
254  $rowReference = (int) $row + (int) trim($rowReference, '[]');
255  }
256  $columnReference = $cellReference[4][0];
257  // Empty C reference is the current column
258  if ($columnReference == '') {
259  $columnReference = $column;
260  }
261  // Bracketed C references are relative to the current column
262  if ($columnReference[0] == '[') {
263  $columnReference = (int) $column + (int) trim($columnReference, '[]');
264  }
265  $A1CellReference = Coordinate::stringFromColumnIndex($columnReference) . $rowReference;
266 
267  $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
268  }
269  }
270  }
271  unset($value);
272  // Then rebuild the formula string
273  $cellDataFormula = implode('"', $temp);
274  $hasCalculatedValue = true;
275  }
$row
$key
Definition: croninfo.php:18
static stringFromColumnIndex($columnIndex)
String from column index.
Definition: Coordinate.php:313
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processFRecord()

PhpOffice\PhpSpreadsheet\Reader\Slk::processFRecord ( array  $rowData,
Spreadsheet $spreadsheet,
string &  $row,
string &  $column 
)
private

Definition at line 321 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\addFonts(), PhpOffice\PhpSpreadsheet\Reader\Slk\addFormats(), PhpOffice\PhpSpreadsheet\Reader\Slk\addStyle(), PhpOffice\PhpSpreadsheet\Reader\Slk\addWidth(), and PhpOffice\PhpSpreadsheet\Reader\Slk\styleSettings().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\loadIntoExisting().

321  : void
322  {
323  // Read cell formatting
324  $formatStyle = $columnWidth = '';
325  $startCol = $endCol = '';
326  $fontStyle = '';
327  $styleData = [];
328  foreach ($rowData as $rowDatum) {
329  switch ($rowDatum[0]) {
330  case 'C':
331  case 'X':
332  $column = substr($rowDatum, 1);
333 
334  break;
335  case 'R':
336  case 'Y':
337  $row = substr($rowDatum, 1);
338 
339  break;
340  case 'P':
341  $formatStyle = $rowDatum;
342 
343  break;
344  case 'W':
345  [$startCol, $endCol, $columnWidth] = explode(' ', substr($rowDatum, 1));
346 
347  break;
348  case 'S':
349  $this->styleSettings($rowDatum, $styleData, $fontStyle);
350 
351  break;
352  }
353  }
354  $this->addFormats($spreadsheet, $formatStyle, $row, $column);
355  $this->addFonts($spreadsheet, $fontStyle, $row, $column);
356  $this->addStyle($spreadsheet, $styleData, $row, $column);
357  $this->addWidth($spreadsheet, $columnWidth, $startCol, $endCol);
358  }
addFonts(Spreadsheet &$spreadsheet, string $fontStyle, string $row, string $column)
Definition: Slk.php:399
addStyle(Spreadsheet &$spreadsheet, array $styleData, string $row, string $column)
Definition: Slk.php:409
addWidth(Spreadsheet $spreadsheet, string $columnWidth, string $startCol, string $endCol)
Definition: Slk.php:417
$row
addFormats(Spreadsheet &$spreadsheet, string $formatStyle, string $row, string $column)
Definition: Slk.php:389
styleSettings(string $rowDatum, array &$styleData, string &$fontStyle)
Definition: Slk.php:369
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processPColors()

PhpOffice\PhpSpreadsheet\Reader\Slk::processPColors ( string  $rowDatum,
array &  $formatArray 
)
private

Definition at line 468 of file Slk.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processPRecord().

468  : void
469  {
470  if (preg_match('/L([1-9]\\d*)/', $rowDatum, $matches)) {
471  $fontColor = $matches[1] % 8;
472  $formatArray['font']['color']['argb'] = $this->colorArray[$fontColor];
473  }
474  }
+ Here is the caller graph for this function:

◆ processPFinal()

PhpOffice\PhpSpreadsheet\Reader\Slk::processPFinal ( Spreadsheet $spreadsheet,
array  $formatArray 
)
private

Definition at line 487 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\$fontcount, PhpOffice\PhpSpreadsheet\Reader\Slk\$format, and PhpOffice\PhpSpreadsheet\Spreadsheet\getDefaultStyle().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processPRecord().

487  : void
488  {
489  if (array_key_exists('numberFormat', $formatArray)) {
490  $this->formats['P' . $this->format] = $formatArray;
491  ++$this->format;
492  } elseif (array_key_exists('font', $formatArray)) {
494  $this->fonts[$this->fontcount] = $formatArray;
495  if ($this->fontcount === 1) {
496  $spreadsheet->getDefaultStyle()->applyFromArray($formatArray);
497  }
498  }
499  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processPFontStyles()

PhpOffice\PhpSpreadsheet\Reader\Slk::processPFontStyles ( string  $rowDatum,
array &  $formatArray 
)
private

Definition at line 476 of file Slk.php.

References $i.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processPRecord().

476  : void
477  {
478  $styleSettings = substr($rowDatum, 1);
479  $iMax = strlen($styleSettings);
480  for ($i = 0; $i < $iMax; ++$i) {
481  if (array_key_exists($styleSettings[$i], $this->fontStyleMappings)) {
482  $formatArray['font'][$this->fontStyleMappings[$styleSettings[$i]]] = true;
483  }
484  }
485  }
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ processPRecord()

PhpOffice\PhpSpreadsheet\Reader\Slk::processPRecord ( array  $rowData,
Spreadsheet $spreadsheet 
)
private

Definition at line 434 of file Slk.php.

References PhpOffice\PhpSpreadsheet\Reader\Slk\processPColors(), PhpOffice\PhpSpreadsheet\Reader\Slk\processPFinal(), and PhpOffice\PhpSpreadsheet\Reader\Slk\processPFontStyles().

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\loadIntoExisting().

434  : void
435  {
436  // Read shared styles
437  $formatArray = [];
438  $fromFormats = ['\-', '\ '];
439  $toFormats = ['-', ' '];
440  foreach ($rowData as $rowDatum) {
441  switch ($rowDatum[0]) {
442  case 'P':
443  $formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
444 
445  break;
446  case 'E':
447  case 'F':
448  $formatArray['font']['name'] = substr($rowDatum, 1);
449 
450  break;
451  case 'M':
452  $formatArray['font']['size'] = substr($rowDatum, 1) / 20;
453 
454  break;
455  case 'L':
456  $this->processPColors($rowDatum, $formatArray);
457 
458  break;
459  case 'S':
460  $this->processPFontStyles($rowDatum, $formatArray);
461 
462  break;
463  }
464  }
465  $this->processPFinal($spreadsheet, $formatArray);
466  }
processPFinal(Spreadsheet &$spreadsheet, array $formatArray)
Definition: Slk.php:487
processPColors(string $rowDatum, array &$formatArray)
Definition: Slk.php:468
processPFontStyles(string $rowDatum, array &$formatArray)
Definition: Slk.php:476
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setInputEncoding()

PhpOffice\PhpSpreadsheet\Reader\Slk::setInputEncoding (   $pValue)

Set input encoding.

Deprecated:
no use is made of this property
Parameters
string$pValueInput encoding, eg: 'ANSI'
Returns
$this

Definition at line 116 of file Slk.php.

117  {
118  $this->inputEncoding = $pValue;
119 
120  return $this;
121  }

◆ setSheetIndex()

PhpOffice\PhpSpreadsheet\Reader\Slk::setSheetIndex (   $pValue)

Set sheet index.

Parameters
int$pValueSheet index
Returns
$this

Definition at line 585 of file Slk.php.

586  {
587  $this->sheetIndex = $pValue;
588 
589  return $this;
590  }

◆ styleSettings()

PhpOffice\PhpSpreadsheet\Reader\Slk::styleSettings ( string  $rowDatum,
array &  $styleData,
string &  $fontStyle 
)
private

Definition at line 369 of file Slk.php.

References $i, PhpOffice\PhpSpreadsheet\Style\Border\BORDER_THIN, and PhpOffice\PhpSpreadsheet\Style\Fill\FILL_PATTERN_GRAY125.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processFRecord().

369  : void
370  {
371  $styleSettings = substr($rowDatum, 1);
372  $iMax = strlen($styleSettings);
373  for ($i = 0; $i < $iMax; ++$i) {
374  $char = $styleSettings[$i];
375  if (array_key_exists($char, $this->styleSettingsFont)) {
376  $styleData['font'][$this->styleSettingsFont[$char]] = true;
377  } elseif (array_key_exists($char, $this->styleSettingsBorder)) {
378  $styleData['borders'][$this->styleSettingsBorder[$char]]['borderStyle'] = Border::BORDER_THIN;
379  } elseif ($char == 'S') {
380  $styleData['fill']['fillType'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125;
381  } elseif ($char == 'M') {
382  if (preg_match('/M([1-9]\\d*)/', $styleSettings, $matches)) {
383  $fontStyle = $matches[1];
384  }
385  }
386  }
387  }
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

Field Documentation

◆ $colorArray

PhpOffice\PhpSpreadsheet\Reader\Slk::$colorArray
private
Initial value:
= [
'FF00FFFF',
'FF000000',
'FFFFFFFF',
'FFFF0000',
'FF00FF00',
'FF0000FF',
'FFFFFF00',
'FFFF00FF',
]

Definition at line 213 of file Slk.php.

◆ $fontcount

PhpOffice\PhpSpreadsheet\Reader\Slk::$fontcount = 0
private

Definition at line 56 of file Slk.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processPFinal().

◆ $fonts

PhpOffice\PhpSpreadsheet\Reader\Slk::$fonts = []
private

Definition at line 49 of file Slk.php.

◆ $fontStyleMappings

PhpOffice\PhpSpreadsheet\Reader\Slk::$fontStyleMappings
private
Initial value:
= [
'B' => 'bold'

Definition at line 224 of file Slk.php.

◆ $format

PhpOffice\PhpSpreadsheet\Reader\Slk::$format = 0
private

Definition at line 42 of file Slk.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\processPFinal().

◆ $formats

PhpOffice\PhpSpreadsheet\Reader\Slk::$formats = []
private

Definition at line 35 of file Slk.php.

◆ $inputEncoding

PhpOffice\PhpSpreadsheet\Reader\Slk::$inputEncoding = 'ANSI'
private

Definition at line 21 of file Slk.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Slk\getInputEncoding().

◆ $sheetIndex

PhpOffice\PhpSpreadsheet\Reader\Slk::$sheetIndex = 0
private

◆ $styleSettingsBorder

PhpOffice\PhpSpreadsheet\Reader\Slk::$styleSettingsBorder
private
Initial value:
= [
'B' => 'bottom'

Definition at line 362 of file Slk.php.

◆ $styleSettingsFont

PhpOffice\PhpSpreadsheet\Reader\Slk::$styleSettingsFont = ['D' => 'bold'
private

Definition at line 360 of file Slk.php.


The documentation for this class was generated from the following file: