52 $this->_rowCallback = $rowCallback;
64 if (empty($sheetName)) {
65 $sheetName =
'Sheet 1';
68 $sheetName = htmlspecialchars($sheetName);
71 '?xml version="1.0"?' .
73 '?mso-application progid="Excel.Sheet"?' .
75 ' xmlns="urn:schemas-microsoft-com:office:spreadsheet"' .
76 ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' .
77 ' xmlns:x="urn:schemas-microsoft-com:office:excel"' .
78 ' xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml"' .
79 ' xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"' .
80 ' xmlns:o="urn:schemas-microsoft-com:office:office"' .
81 ' xmlns:html="http://www.w3.org/TR/REC-html40"' .
82 ' xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet">' .
83 '<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">' .
84 '</OfficeDocumentSettings>' .
85 '<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">' .
87 '<Worksheet ss:Name="' .
92 if ($this->_dataHeader) {
93 $xmlHeader .= $this->_getXmlRow($this->_dataHeader,
false);
109 if ($this->_dataFooter) {
110 $xmlFooter = $this->_getXmlRow($this->_dataFooter,
false);
113 $xmlFooter .=
'</Table></Worksheet></Workbook>';
127 protected function _getXmlRow(
$row, $useCallback)
129 if ($useCallback && $this->_rowCallback) {
133 $xmlData[] =
'<Row>';
137 $dataType = is_numeric(
$value) &&
$value[0] !==
'+' &&
$value[0] !==
'0' ?
'Number' :
'String';
148 if (isset(
$value[0]) && in_array(
$value[0], [
'=',
'+',
'-'])) {
150 $dataType =
'String';
157 $xmlData[] =
'<Cell><Data ss:Type="' . $dataType .
'">' .
$value .
'</Data></Cell>';
159 $xmlData[] =
'</Row>';
161 return join(
'', $xmlData);
172 $this->_dataHeader =
$data;
183 $this->_dataFooter =
$data;
196 foreach ($this->_iterator as $dataRow) {
197 $xml .= $this->_getXmlRow($dataRow,
true);
215 foreach ($this->_iterator as $dataRow) {
216 $stream->
write($this->_getXmlRow($dataRow,
true));
write(WriteInterface $stream, $sheetName='')
call_user_func($callable, $param)
__construct(\Iterator $iterator, $rowCallback=[])
_getXmlHeader($sheetName='')