From 9cc2f8d50b83628ef99c4f5b6227e102b5ed51ae Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 21 Jan 2011 14:36:28 +0000 Subject: [PATCH] Feature: Added basic support for cell comments in the OOCalc Reader git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@67188 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Reader/OOCalc.php | 25 +++++++++++++++++++++++++ changelog.txt | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Reader/OOCalc.php b/Classes/PHPExcel/Reader/OOCalc.php index 84f259f0..7aab6de0 100644 --- a/Classes/PHPExcel/Reader/OOCalc.php +++ b/Classes/PHPExcel/Reader/OOCalc.php @@ -405,6 +405,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader // echo ''.$columnID.$rowID.'
'; $cellDataText = $cellData->children($namespacesContent['text']); + $cellDataOffice = $cellData->children($namespacesContent['office']); $cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']); $cellDataTableAttributes = $cellData->attributes($namespacesContent['table']); @@ -424,6 +425,22 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader $hasCalculatedValue = true; } + if (isset($cellDataOffice->annotation)) { +// echo 'Cell has comment
'; + $annotationText = $cellDataOffice->annotation->children($namespacesContent['text']); + $textArray = array(); + foreach($annotationText as $t) { + foreach($t->span as $text) { + $textArray[] = (string)$text; + } + } + $text = implode("\n",$textArray); +// echo $text,'
'; + $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) +// ->setAuthor( $author ) + ->setText($this->_parseRichText($text) ); + } + if (isset($cellDataText->p)) { // echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'
'; switch ($cellDataOfficeAttributes['value-type']) { @@ -539,4 +556,12 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader return $objPHPExcel; } + private function _parseRichText($is = '') { + $value = new PHPExcel_RichText(); + + $value->createText($is); + + return $value; + } + } diff --git a/changelog.txt b/changelog.txt index 4ffc5522..b7ec29b8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,7 +33,7 @@ Fixed in SVN: - Feature: (MBaker) Added new rangeToArray() and namedRangeToArray() methods to the PHPExcel_Worksheet object. Functionally, these are identical to the toArray() method, except that they take an additional first parameter of a Range (e.g. 'B2:C3') or a Named Range name. Modified the toArray() method so that it actually uses rangeToArray(). -- Feature: (MBaker) Added support for cell comments in the Gnumeric and Excel2003XML Readers +- Feature: (MBaker) Added support for cell comments in the OOCalc, Gnumeric and Excel2003XML Readers - Bugfix: (MBaker) Work item 14888 - Simple =IF() formula disappears - Bugfix: (MBaker) Work item 14898 - PHP Warning: preg_match(): Compilation failed: PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X - Bugfix: (MBaker) Work item 14901 - VLOOKUP choking on parameters in PHPExcel.1.7.5/PHPExcel_Writer_Excel2007