1 | <?php |
||
13 | class Sheet |
||
14 | { |
||
15 | const DEFAULT_SHEET_NAME_PREFIX = 'Sheet'; |
||
16 | |||
17 | /** @var int Index of the sheet, based on order in the workbook (zero-based) */ |
||
18 | private $index; |
||
19 | |||
20 | /** @var string ID of the sheet's associated workbook. Used to restrict sheet name uniqueness enforcement to a single workbook */ |
||
21 | private $associatedWorkbookId; |
||
22 | |||
23 | /** @var string Name of the sheet */ |
||
24 | private $name; |
||
25 | |||
26 | /** |
||
27 | * @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based) |
||
28 | * @param string $associatedWorkbookId ID of the sheet's associated workbook |
||
29 | * @param SheetManager $sheetManager |
||
30 | */ |
||
31 | 107 | public function __construct($sheetIndex, $associatedWorkbookId, SheetManager $sheetManager) |
|
41 | |||
42 | /** |
||
43 | * @api |
||
44 | * @return int Index of the sheet, based on order in the workbook (zero-based) |
||
45 | */ |
||
46 | 107 | public function getIndex() |
|
50 | |||
51 | /** |
||
52 | * @return string |
||
53 | */ |
||
54 | 107 | public function getAssociatedWorkbookId() |
|
58 | |||
59 | /** |
||
60 | * @api |
||
61 | * @return string Name of the sheet |
||
62 | */ |
||
63 | 107 | public function getName() |
|
67 | |||
68 | /** |
||
69 | * Sets the name of the sheet. Note that Excel has some restrictions on the name: |
||
70 | * - it should not be blank |
||
71 | * - it should not exceed 31 characters |
||
72 | * - it should not contain these characters: \ / ? * : [ or ] |
||
73 | * - it should be unique |
||
74 | * |
||
75 | * @api |
||
76 | * @param string $name Name of the sheet |
||
77 | * @return Sheet |
||
78 | * @throws \Box\Spout\Writer\Exception\InvalidSheetNameException If the sheet's name is invalid. |
||
79 | */ |
||
80 | 107 | public function setName($name) |
|
90 | } |
||
91 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: