1 | <?php |
||
14 | class SheetHelper |
||
15 | { |
||
16 | /** Paths of XML files relative to the XLSX file root */ |
||
17 | const WORKBOOK_XML_RELS_FILE_PATH = 'xl/_rels/workbook.xml.rels'; |
||
18 | const WORKBOOK_XML_FILE_PATH = 'xl/workbook.xml'; |
||
19 | |||
20 | /** Definition of XML node names used to parse data */ |
||
21 | const XML_NODE_WORKBOOK_VIEW = 'workbookView'; |
||
22 | const XML_NODE_SHEET = 'sheet'; |
||
23 | const XML_NODE_SHEETS = 'sheets'; |
||
24 | const XML_NODE_RELATIONSHIP = 'Relationship'; |
||
25 | |||
26 | /** Definition of XML attributes used to parse data */ |
||
27 | const XML_ATTRIBUTE_ACTIVE_TAB = 'activeTab'; |
||
28 | const XML_ATTRIBUTE_R_ID = 'r:id'; |
||
29 | const XML_ATTRIBUTE_NAME = 'name'; |
||
30 | const XML_ATTRIBUTE_ID = 'Id'; |
||
31 | const XML_ATTRIBUTE_TARGET = 'Target'; |
||
32 | |||
33 | /** @var string Path of the XLSX file being read */ |
||
34 | protected $filePath; |
||
35 | |||
36 | /** @var \Box\Spout\Reader\XLSX\ReaderOptions Reader's current options */ |
||
37 | protected $options; |
||
38 | |||
39 | /** @var \Box\Spout\Reader\XLSX\Helper\SharedStringsHelper Helper to work with shared strings */ |
||
40 | protected $sharedStringsHelper; |
||
41 | |||
42 | /** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper Helper to work with global functions */ |
||
43 | protected $globalFunctionsHelper; |
||
44 | |||
45 | /** |
||
46 | * @param string $filePath Path of the XLSX file being read |
||
47 | * @param \Box\Spout\Reader\XLSX\ReaderOptions $options Reader's current options |
||
48 | * @param \Box\Spout\Reader\XLSX\Helper\SharedStringsHelper Helper to work with shared strings |
||
49 | * @param \Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper |
||
50 | */ |
||
51 | 34 | public function __construct($filePath, $options, $sharedStringsHelper, $globalFunctionsHelper) |
|
58 | |||
59 | /** |
||
60 | * Returns the sheets metadata of the file located at the previously given file path. |
||
61 | * The paths to the sheets' data are read from the [Content_Types].xml file. |
||
62 | * |
||
63 | * @return Sheet[] Sheets within the XLSX file |
||
64 | */ |
||
65 | 34 | public function getSheets() |
|
93 | |||
94 | /** |
||
95 | * Returns an instance of a sheet, given the XML node describing the sheet - from "workbook.xml". |
||
96 | * We can find the XML file path describing the sheet inside "workbook.xml.res", by mapping with the sheet ID |
||
97 | * ("r:id" in "workbook.xml", "Id" in "workbook.xml.res"). |
||
98 | * |
||
99 | * @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReaderOnSheetNode XML Reader instance, pointing on the node describing the sheet, as defined in "workbook.xml" |
||
100 | * @param int $sheetIndexZeroBased Index of the sheet, based on order of appearance in the workbook (zero-based) |
||
101 | * @param bool $isSheetActive Whether this sheet was defined as active |
||
102 | * @return \Box\Spout\Reader\XLSX\Sheet Sheet instance |
||
103 | */ |
||
104 | 33 | protected function getSheetFromSheetXMLNode($xmlReaderOnSheetNode, $sheetIndexZeroBased, $isSheetActive) |
|
121 | |||
122 | /** |
||
123 | * @param string $sheetId The sheet ID, as defined in "workbook.xml" |
||
124 | * @return string The XML file path describing the sheet inside "workbook.xml.res", for the given sheet ID |
||
125 | */ |
||
126 | 33 | protected function getSheetDataXMLFilePathForSheetId($sheetId) |
|
156 | } |
||
157 |