| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\OpenSpout\Writer\Common\Entity; |
| 4 |
|
| 5 |
/** |
| 6 |
* Entity describing a Worksheet. |
| 7 |
*/ |
| 8 |
class Worksheet |
| 9 |
{ |
| 10 |
/** @var string Path to the XML file that will contain the sheet data */ |
| 11 |
private $filePath; |
| 12 |
/** @var null|resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */ |
| 13 |
private $filePointer; |
| 14 |
/** @var Sheet The "external" sheet */ |
| 15 |
private $externalSheet; |
| 16 |
/** @var int Maximum number of columns among all the written rows */ |
| 17 |
private $maxNumColumns; |
| 18 |
/** @var int Index of the last written row */ |
| 19 |
private $lastWrittenRowIndex; |
| 20 |
/** @var bool has the sheet data header been written */ |
| 21 |
private $sheetDataStarted = \false; |
| 22 |
/** |
| 23 |
* Worksheet constructor. |
| 24 |
* |
| 25 |
* @param string $worksheetFilePath |
| 26 |
*/ |
| 27 |
public function __construct($worksheetFilePath, Sheet $externalSheet) |
| 28 |
{ |
| 29 |
$this->filePath = $worksheetFilePath; |
| 30 |
$this->filePointer = null; |
| 31 |
$this->externalSheet = $externalSheet; |
| 32 |
$this->maxNumColumns = 0; |
| 33 |
$this->lastWrittenRowIndex = 0; |
| 34 |
$this->sheetDataStarted = \false; |
| 35 |
} |
| 36 |
/** |
| 37 |
* @return string |
| 38 |
*/ |
| 39 |
public function getFilePath() |
| 40 |
{ |
| 41 |
return $this->filePath; |
| 42 |
} |
| 43 |
/** |
| 44 |
* @return resource |
| 45 |
*/ |
| 46 |
public function getFilePointer() |
| 47 |
{ |
| 48 |
return $this->filePointer; |
| 49 |
} |
| 50 |
/** |
| 51 |
* @param resource $filePointer |
| 52 |
*/ |
| 53 |
public function setFilePointer($filePointer) |
| 54 |
{ |
| 55 |
$this->filePointer = $filePointer; |
| 56 |
} |
| 57 |
/** |
| 58 |
* @return Sheet |
| 59 |
*/ |
| 60 |
public function getExternalSheet() |
| 61 |
{ |
| 62 |
return $this->externalSheet; |
| 63 |
} |
| 64 |
/** |
| 65 |
* @return int |
| 66 |
*/ |
| 67 |
public function getMaxNumColumns() |
| 68 |
{ |
| 69 |
return $this->maxNumColumns; |
| 70 |
} |
| 71 |
/** |
| 72 |
* @param int $maxNumColumns |
| 73 |
*/ |
| 74 |
public function setMaxNumColumns($maxNumColumns) |
| 75 |
{ |
| 76 |
$this->maxNumColumns = $maxNumColumns; |
| 77 |
} |
| 78 |
/** |
| 79 |
* @return int |
| 80 |
*/ |
| 81 |
public function getLastWrittenRowIndex() |
| 82 |
{ |
| 83 |
return $this->lastWrittenRowIndex; |
| 84 |
} |
| 85 |
/** |
| 86 |
* @param int $lastWrittenRowIndex |
| 87 |
*/ |
| 88 |
public function setLastWrittenRowIndex($lastWrittenRowIndex) |
| 89 |
{ |
| 90 |
$this->lastWrittenRowIndex = $lastWrittenRowIndex; |
| 91 |
} |
| 92 |
/** |
| 93 |
* @return int The ID of the worksheet |
| 94 |
*/ |
| 95 |
public function getId() |
| 96 |
{ |
| 97 |
// sheet index is zero-based, while ID is 1-based |
| 98 |
return $this->externalSheet->getIndex() + 1; |
| 99 |
} |
| 100 |
/** |
| 101 |
* @return bool |
| 102 |
*/ |
| 103 |
public function getSheetDataStarted() |
| 104 |
{ |
| 105 |
return $this->sheetDataStarted; |
| 106 |
} |
| 107 |
/** |
| 108 |
* @param bool $sheetDataStarted |
| 109 |
*/ |
| 110 |
public function setSheetDataStarted($sheetDataStarted) |
| 111 |
{ |
| 112 |
$this->sheetDataStarted = $sheetDataStarted; |
| 113 |
} |
| 114 |
} |
| 115 |
|