30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../../');
38 require_once PHPEXCEL_ROOT .
'PHPExcel.php';
41 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/Excel2007.php';
44 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/Excel2007/WriterPart.php';
47 require_once PHPEXCEL_ROOT .
'PHPExcel/Worksheet.php';
50 require_once PHPEXCEL_ROOT .
'PHPExcel/Comment.php';
53 require_once PHPEXCEL_ROOT .
'PHPExcel/RichText.php';
56 require_once PHPEXCEL_ROOT .
'PHPExcel/Cell.php';
59 require_once PHPEXCEL_ROOT .
'PHPExcel/Style/Color.php';
62 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/XMLWriter.php';
92 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
95 $comments = $pWorksheet->getComments();
101 if (!isset($authors[$comment->getAuthor()])) {
102 $authors[$comment->getAuthor()] = $authorId++;
107 $objWriter->startElement(
'comments');
108 $objWriter->writeAttribute(
'xmlns',
'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
111 $objWriter->startElement(
'authors');
112 foreach ($authors as $author => $index) {
113 $objWriter->writeElement(
'author', $author);
115 $objWriter->endElement();
118 $objWriter->startElement(
'commentList');
119 foreach ($comments as
$key => $value) {
122 $objWriter->endElement();
124 $objWriter->endElement();
127 return $objWriter->getData();
142 $objWriter->startElement(
'comment');
143 $objWriter->writeAttribute(
'ref', $pCellReference);
144 $objWriter->writeAttribute(
'authorId', $pAuthors[$pComment->getAuthor()]);
147 $objWriter->startElement(
'text');
148 $this->
getParentWriter()->getWriterPart(
'stringtable')->writeRichText($objWriter, $pComment->getText());
149 $objWriter->endElement();
151 $objWriter->endElement();
172 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
175 $comments = $pWorksheet->getComments();
178 $objWriter->startElement(
'xml');
179 $objWriter->writeAttribute(
'xmlns:v',
'urn:schemas-microsoft-com:vml');
180 $objWriter->writeAttribute(
'xmlns:o',
'urn:schemas-microsoft-com:office:office');
181 $objWriter->writeAttribute(
'xmlns:x',
'urn:schemas-microsoft-com:office:excel');
184 $objWriter->startElement(
'o:shapelayout');
185 $objWriter->writeAttribute(
'v:ext',
'edit');
188 $objWriter->startElement(
'o:idmap');
189 $objWriter->writeAttribute(
'v:ext',
'edit');
190 $objWriter->writeAttribute(
'data',
'1');
191 $objWriter->endElement();
193 $objWriter->endElement();
196 $objWriter->startElement(
'v:shapetype');
197 $objWriter->writeAttribute(
'id',
'_x0000_t202');
198 $objWriter->writeAttribute(
'coordsize',
'21600,21600');
199 $objWriter->writeAttribute(
'o:spt',
'202');
200 $objWriter->writeAttribute(
'path',
'm,l,21600r21600,l21600,xe');
203 $objWriter->startElement(
'v:stroke');
204 $objWriter->writeAttribute(
'joinstyle',
'miter');
205 $objWriter->endElement();
208 $objWriter->startElement(
'v:path');
209 $objWriter->writeAttribute(
'gradientshapeok',
't');
210 $objWriter->writeAttribute(
'o:connecttype',
'rect');
211 $objWriter->endElement();
213 $objWriter->endElement();
216 foreach ($comments as
$key => $value) {
220 $objWriter->endElement();
223 return $objWriter->getData();
239 $id = 1024 + $column +
$row;
240 $id = substr($id, 0, 4);
243 $objWriter->startElement(
'v:shape');
244 $objWriter->writeAttribute(
'id',
'_x0000_s' . $id);
245 $objWriter->writeAttribute(
'type',
'#_x0000_t202');
246 $objWriter->writeAttribute(
'style',
'position:absolute;margin-left:' . $pComment->getMarginLeft() .
';margin-top:' . $pComment->getMarginTop() .
';width:' . $pComment->getWidth() .
';height:' . $pComment->getHeight() .
';z-index:1;visibility:' . ($pComment->getVisible() ?
'visible' :
'hidden'));
247 $objWriter->writeAttribute(
'fillcolor',
'#' . $pComment->getFillColor()->getRGB());
248 $objWriter->writeAttribute(
'o:insetmode',
'auto');
251 $objWriter->startElement(
'v:fill');
252 $objWriter->writeAttribute(
'color2',
'#' . $pComment->getFillColor()->getRGB());
253 $objWriter->endElement();
256 $objWriter->startElement(
'v:shadow');
257 $objWriter->writeAttribute(
'on',
't');
258 $objWriter->writeAttribute(
'color',
'black');
259 $objWriter->writeAttribute(
'obscured',
't');
260 $objWriter->endElement();
263 $objWriter->startElement(
'v:path');
264 $objWriter->writeAttribute(
'o:connecttype',
'none');
265 $objWriter->endElement();
268 $objWriter->startElement(
'v:textbox');
269 $objWriter->writeAttribute(
'style',
'mso-direction-alt:auto');
272 $objWriter->startElement(
'div');
273 $objWriter->writeAttribute(
'style',
'text-align:left');
274 $objWriter->endElement();
276 $objWriter->endElement();
279 $objWriter->startElement(
'x:ClientData');
280 $objWriter->writeAttribute(
'ObjectType',
'Note');
283 $objWriter->writeElement(
'x:MoveWithCells',
'');
286 $objWriter->writeElement(
'x:SizeWithCells',
'');
292 $objWriter->writeElement(
'x:AutoFill',
'False');
295 $objWriter->writeElement(
'x:Row', ($row - 1));
298 $objWriter->writeElement(
'x:Column', ($column - 1));
300 $objWriter->endElement();
302 $objWriter->endElement();