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