1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Box\Spout\Reader\XLSX\Creator; |
4
|
|
|
|
5
|
|
|
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface; |
6
|
|
|
use Box\Spout\Reader\Common\XMLProcessor; |
7
|
|
|
use Box\Spout\Reader\XLSX\Helper\SharedStringsHelper; |
8
|
|
|
use Box\Spout\Reader\XLSX\RowIterator; |
9
|
|
|
use Box\Spout\Reader\XLSX\Sheet; |
10
|
|
|
use Box\Spout\Reader\XLSX\SheetIterator; |
11
|
|
|
use Box\Spout\Reader\Wrapper\XMLReader; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class EntityFactory |
15
|
|
|
* Factory to create entities |
16
|
|
|
* |
17
|
|
|
* @package Box\Spout\Reader\XLSX\Creator |
18
|
|
|
*/ |
19
|
|
|
class EntityFactory implements EntityFactoryInterface |
20
|
|
|
{ |
21
|
|
|
/** @var HelperFactory */ |
22
|
|
|
private $helperFactory; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param HelperFactory $helperFactory |
26
|
|
|
*/ |
27
|
78 |
|
public function __construct(HelperFactory $helperFactory) |
28
|
|
|
{ |
29
|
78 |
|
$this->helperFactory = $helperFactory; |
30
|
78 |
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param string $filePath Path of the file to be read |
34
|
|
|
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager |
35
|
|
|
* @param SharedStringsHelper $sharedStringsHelper Helper to work with shared strings |
36
|
|
|
* @param \Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper |
37
|
|
|
* @return SheetIterator |
38
|
|
|
*/ |
39
|
34 |
|
public function createSheetIterator($filePath, $optionsManager, $sharedStringsHelper, $globalFunctionsHelper) |
40
|
|
|
{ |
41
|
34 |
|
return new SheetIterator( |
42
|
34 |
|
$filePath, |
43
|
34 |
|
$optionsManager, |
44
|
34 |
|
$sharedStringsHelper, |
45
|
34 |
|
$globalFunctionsHelper, |
46
|
34 |
|
$this, |
47
|
34 |
|
$this->helperFactory |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $filePath Path of the XLSX file being read |
53
|
|
|
* @param string $sheetDataXMLFilePath Path of the sheet data XML file as in [Content_Types].xml |
54
|
|
|
* @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based) |
55
|
|
|
* @param string $sheetName Name of the sheet |
56
|
|
|
* @param bool $isSheetActive Whether the sheet was defined as active |
57
|
|
|
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager |
58
|
|
|
* @param SharedStringsHelper $sharedStringsHelper Helper to work with shared strings |
59
|
|
|
* @return Sheet |
60
|
|
|
*/ |
61
|
33 |
|
public function createSheet( |
62
|
|
|
$filePath, |
63
|
|
|
$sheetDataXMLFilePath, |
64
|
|
|
$sheetIndex, |
65
|
|
|
$sheetName, |
66
|
|
|
$isSheetActive, |
67
|
|
|
$optionsManager, |
68
|
|
|
$sharedStringsHelper) |
69
|
|
|
{ |
70
|
33 |
|
return new Sheet( |
71
|
33 |
|
$filePath, |
72
|
33 |
|
$sheetDataXMLFilePath, |
73
|
33 |
|
$sheetIndex, |
74
|
33 |
|
$sheetName, |
75
|
33 |
|
$isSheetActive, |
76
|
33 |
|
$optionsManager, |
77
|
33 |
|
$sharedStringsHelper, |
78
|
33 |
|
$this |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param string $filePath Path of the XLSX file being read |
84
|
|
|
* @param string $sheetDataXMLFilePath Path of the sheet data XML file as in [Content_Types].xml |
85
|
|
|
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager |
86
|
|
|
* @param SharedStringsHelper $sharedStringsHelper Helper to work with shared strings |
87
|
|
|
* @return RowIterator |
88
|
|
|
*/ |
89
|
33 |
|
public function createRowIterator($filePath, $sheetDataXMLFilePath, $optionsManager, $sharedStringsHelper) |
90
|
|
|
{ |
91
|
33 |
|
return new RowIterator($filePath, $sheetDataXMLFilePath, $optionsManager, $sharedStringsHelper, $this, $this->helperFactory); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return \ZipArchive |
96
|
|
|
*/ |
97
|
36 |
|
public function createZipArchive() |
98
|
|
|
{ |
99
|
36 |
|
return new \ZipArchive(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return XMLReader |
104
|
|
|
*/ |
105
|
41 |
|
public function createXMLReader() |
106
|
|
|
{ |
107
|
41 |
|
return new XMLReader(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param $xmlReader |
112
|
|
|
* @return XMLProcessor |
113
|
|
|
*/ |
114
|
33 |
|
public function createXMLProcessor($xmlReader) |
115
|
|
|
{ |
116
|
33 |
|
return new XMLProcessor($xmlReader); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|