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