1 | <?php |
||
16 | abstract class AbstractExcelBuilder implements ExcelBuilderInterface |
||
17 | { |
||
18 | /** @var array */ |
||
19 | protected $rowIndexes; |
||
20 | |||
21 | /** @var array */ |
||
22 | protected $labels; |
||
23 | |||
24 | /** @var array */ |
||
25 | protected $options; |
||
26 | |||
27 | /** @var PHPExcel */ |
||
28 | protected $xls; |
||
29 | |||
30 | /** @var boolean */ |
||
31 | protected $clean = false; |
||
32 | |||
33 | /** |
||
34 | * @param array $options |
||
35 | */ |
||
36 | public function __construct(array $options = array()) |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | public function add(array $item) |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function getExcelObject() |
||
65 | |||
66 | /** |
||
67 | * Returns the worksheet name for a set of data |
||
68 | * |
||
69 | * @param array $data |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | abstract protected function getWorksheetName(array $data); |
||
74 | |||
75 | /** |
||
76 | * Returns the worksheet for a set of data |
||
77 | * |
||
78 | * @param array $data |
||
79 | * |
||
80 | * @return \PHPExcel_Worksheet |
||
81 | */ |
||
82 | protected function getWorksheet(array $data) |
||
91 | |||
92 | /** |
||
93 | * Creates a worksheet with the given name |
||
94 | * |
||
95 | * @param string $name |
||
96 | * @param array $data |
||
97 | * |
||
98 | * @return PHPExcel_Worksheet |
||
99 | */ |
||
100 | protected function createWorksheet($name, array $data) |
||
109 | |||
110 | /** |
||
111 | * Cleanup the Excel file |
||
112 | */ |
||
113 | protected function cleanup() |
||
119 | |||
120 | /** |
||
121 | * Writes labels for the submitted data |
||
122 | * |
||
123 | * @param PHPExcel_Worksheet $worksheet |
||
124 | * @param array $data |
||
125 | */ |
||
126 | protected function writeLabels(PHPExcel_Worksheet $worksheet, array $data) |
||
137 | |||
138 | /** |
||
139 | * Writes a row of values |
||
140 | * |
||
141 | * @param PHPExcel_Worksheet $worksheet |
||
142 | * @param array $data An array of values with column indexes as keys |
||
143 | */ |
||
144 | protected function writeValues(PHPExcel_Worksheet $worksheet, array $data) |
||
156 | |||
157 | /** |
||
158 | * Sets the default options |
||
159 | * |
||
160 | * @param OptionsResolver $resolver |
||
161 | */ |
||
162 | protected function setDefaultOptions(OptionsResolver $resolver) |
||
171 | } |
||
172 |