48 if (!is_null($pSheet)) {
50 $aStringTable = array();
51 $cellCollection = null;
52 $aFlippedStringTable = null;
55 if (!is_null($pExistingTable) && is_array($pExistingTable)) {
56 $aStringTable = $pExistingTable;
63 foreach ($pSheet->getCellCollection() as $cellID) {
64 $cell = $pSheet->getCell($cellID);
65 $cellValue = $cell->getValue();
66 if (!is_object($cellValue) &&
67 !is_null($cellValue) &&
69 !isset($aFlippedStringTable[$cellValue]) &&
71 $aStringTable[] = $cellValue;
72 $aFlippedStringTable[$cellValue] = 1;
74 !is_null($cellValue) &&
75 !isset($aFlippedStringTable[$cellValue->getHashCode()])) {
76 $aStringTable[] = $cellValue;
77 $aFlippedStringTable[$cellValue->getHashCode()] = 1;
84 throw new Exception(
"Invalid PHPExcel_Worksheet object passed.");
97 if (!is_null($pStringTable)) {
107 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
110 $objWriter->startElement(
'sst');
111 $objWriter->writeAttribute(
'xmlns',
'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
112 $objWriter->writeAttribute(
'uniqueCount', count($pStringTable));
115 foreach ($pStringTable as $textElement) {
116 $objWriter->startElement(
'si');
120 $objWriter->startElement(
't');
121 if ($textToWrite !== trim($textToWrite)) {
122 $objWriter->writeAttribute(
'xml:space',
'preserve');
124 $objWriter->writeRawData($textToWrite);
125 $objWriter->endElement();
126 }
else if ($textElement instanceof PHPExcel_RichText) {
130 $objWriter->endElement();
133 $objWriter->endElement();
136 return $objWriter->getData();
138 throw new Exception(
"Invalid string table array passed.");
152 $elements = $pRichText->getRichTextElements();
153 foreach ($elements as $element) {
155 $objWriter->startElement(
'r');
160 $objWriter->startElement(
'rPr');
163 $objWriter->startElement(
'rFont');
164 $objWriter->writeAttribute(
'val', $element->getFont()->getName());
165 $objWriter->endElement();
168 $objWriter->startElement(
'b');
169 $objWriter->writeAttribute(
'val', ($element->getFont()->getBold() ?
'true' :
'false'));
170 $objWriter->endElement();
173 $objWriter->startElement(
'i');
174 $objWriter->writeAttribute(
'val', ($element->getFont()->getItalic() ?
'true' :
'false'));
175 $objWriter->endElement();
178 if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
179 $objWriter->startElement(
'vertAlign');
180 if ($element->getFont()->getSuperScript()) {
181 $objWriter->writeAttribute(
'val',
'superscript');
182 }
else if ($element->getFont()->getSubScript()) {
183 $objWriter->writeAttribute(
'val',
'subscript');
185 $objWriter->endElement();
189 $objWriter->startElement(
'strike');
190 $objWriter->writeAttribute(
'val', ($element->getFont()->getStrikethrough() ?
'true' :
'false'));
191 $objWriter->endElement();
194 $objWriter->startElement(
'color');
195 $objWriter->writeAttribute(
'rgb', $element->getFont()->getColor()->getARGB());
196 $objWriter->endElement();
199 $objWriter->startElement(
'sz');
200 $objWriter->writeAttribute(
'val', $element->getFont()->getSize());
201 $objWriter->endElement();
204 $objWriter->startElement(
'u');
205 $objWriter->writeAttribute(
'val', $element->getFont()->getUnderline());
206 $objWriter->endElement();
208 $objWriter->endElement();
212 $objWriter->startElement(
't');
213 $objWriter->writeAttribute(
'xml:space',
'preserve');
215 $objWriter->endElement();
217 $objWriter->endElement();
229 $returnValue = array();
232 foreach ($stringTable as $key => $value) {
234 $returnValue[$value] = $key;
235 }
else if ($value instanceof PHPExcel_RichText) {
236 $returnValue[$value->getHashCode()] = $key;