From 2368c7fbd0ce78245af2f4954871ab7a0387de33 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 21 Jan 2011 16:41:02 +0000 Subject: [PATCH] Feature: Added some support for cell annotations in the Excel5 Reader (for BIFF5-7 only at present... BIFF8 support is still outstanding, as annotations were change to a drawing object with this release) git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@67190 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Reader/Excel5.php | 64 ++++++++++++++---- .../Functionality Cross-Reference.xls | Bin 36352 -> 36864 bytes changelog.txt | 2 +- 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/Classes/PHPExcel/Reader/Excel5.php b/Classes/PHPExcel/Reader/Excel5.php index 191f5790..225fd6b9 100644 --- a/Classes/PHPExcel/Reader/Excel5.php +++ b/Classes/PHPExcel/Reader/Excel5.php @@ -820,11 +820,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader $offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024; $offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256; - switch ($obj['type']) { + switch ($obj['otObjType']) { case 0x19: // Note -// echo 'Comment Object
'; +// echo 'Cell Annotation Object
'; break; case 0x08: @@ -1336,26 +1336,40 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _readNote() { -// echo 'Read Note
'; +// echo 'Read Cell Annotation
'; $length = self::_GetInt2d($this->_data, $this->_pos + 2); $recordData = substr($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; - if ($this->_readDataOnly || $this->_version != self::XLS_BIFF8) { + if ($this->_readDataOnly) { return; } -// hexDump($recordData); -// $cellAddress = $this->_readBIFF8CellAddress(substr($recordData, 0, 4)); - $noteObjID = self::_GetInt2d($recordData, 6); - $noteAuthor = trim(substr($recordData, 8)); + if ($this->_version == self::XLS_BIFF8) { + $noteObjID = self::_GetInt2d($recordData, 6); + $noteAuthor = trim(substr($recordData, 8)); + +// echo 'Note Address=',$cellAddress,'
'; +// echo 'Note Object ID=',$noteObjID,'
'; +// echo 'Note Author=',$noteAuthor,'
'; + } else { + $cellAddress = str_replace('$','',$cellAddress); +// $noteLength = self::_GetInt2d($recordData, 4); + $noteText = trim(substr($recordData, 6)); + + +// echo 'Note Address=',$cellAddress,'
'; +// echo 'Note Length=',$noteLength,'
'; +// echo 'Note Text=',$noteText,'
'; + + $this->_phpSheet->getComment( $cellAddress ) +// ->setAuthor( $author ) + ->setText($this->_parseRichText($noteText) ); + } -// echo 'Note Address=',$cellAddress,'
'; -// echo 'Note Object ID=',$noteObjID,'
'; -// echo 'Note Author=',$noteAuthor,'
'; } /** @@ -3747,16 +3761,28 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader } // recordData consists of an array of subrecords looking like this: - // ft: 2 bytes; id number - // cb: 2 bytes; size in bytes of following data + // ft: 2 bytes; ftCmo type (0x15) + // cb: 2 bytes; size in bytes of ftCmo data + // ot: 2 bytes; Object Type + // id: 2 bytes; Object id number + // grbit: 2 bytes; Option Flags // data: var; subrecord data // for now, we are just interested in the second subrecord containing the object type - $ot = self::_GetInt2d($recordData, 4); + $ftCmoType = self::_GetInt2d($recordData, 0); + $cbCmoSize = self::_GetInt2d($recordData, 2); + $otObjType = self::_GetInt2d($recordData, 4); + $idObjID = self::_GetInt2d($recordData, 6); + $grbitOpts = self::_GetInt2d($recordData, 6); $this->_objs[] = array( - 'type' => $ot, + 'ftCmoType' => $ftCmoType, + 'cbCmoSize' => $cbCmoSize, + 'otObjType' => $otObjType, + 'idObjID' => $idObjID, + 'grbitOpts' => $grbitOpts ); + } /** @@ -6491,4 +6517,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader } } + private function _parseRichText($is = '') { + $value = new PHPExcel_RichText(); + + $value->createText($is); + + return $value; + } + } diff --git a/Documentation/Functionality Cross-Reference.xls b/Documentation/Functionality Cross-Reference.xls index 3270fb5e04ab1ef3074f2e1cefda5b0674e65efc..056a2f3a9ed06cc406310d2e775084969e973eef 100644 GIT binary patch delta 1367 zcma)5TWnNS6kX@uJC~WE^I#|=m0AWXV2DZ!1qzljw6vut$?!6b5#!8sN};7RLkXdY zcEpGw6jOSCnouH@A0r<=t`Z=`N}@kHAzJt%#4kS#Hsk_{5CW8S&OESuF(>=1efRt9 zy(crOWln2DRigPs^*o~qz;|1|5%!dLSqNAk7^T*z?t3ooCuNt_7ts2azEIueR+ZsV zT-b^k0ToB;r^h{S6f#^daxv2wc1c%h$`7vxmo!#KQlh9U@8iEg=`0M1yt3DoPvAHB zg4*d`3}j`CVQ&^tibs@rw7WI`3yT{YHu<14AF=SfRB?W^Wu-=cUO0?{TtTO$u1WVDg$av zAWOVOT>c`kV+Qaoae^402h_S5gE&h3iwF-)g% zgta6!YM-dTROx%fiL~;aji}`AkQSOu+y4zh4lsDc35k!!+dN2x^s@-0T|A!L;;Tzv@X}r9?;-bmY@~8 zp)5Wkep!-}3(8qM&Tuwz>KU{jnGnZR!D(t6Cs3Da;d9?Tsfc)uK=6l>8?mayepMn<85edZeG#y`l`sj zp6)}DcweM9o!X!3>8n!?71+Qfo{5+6A+b`00Q(+RbCexqQ=W#i>e|=(<%FfCRoV#a zv-UA!RXHx)VV}x)G#^INlj2!MKvgdFQ@!?>+a;ywV&mRryR0 zJ2BfE6hi=>oSkR7!FDpH%7pOCs>AnR(F?0?*|CGF*Bra8JtTXC+lm4*E}AVLGvDa@ zRMaMXs7G-{RGen3SxN_w8;hK7$MHwfoOX}8O6ms8FgrQsv`>$Ve{NZNJn! zq*tlkpsOCmYmqwIXjD?{2_5EWPkpqD4dMa{$RmkyEEJb6 zJ$u6(`bwd@S&o$zofnr{qQ4Bo*iRn)gad>K;UM7`LFv2k dZ8jk)<#oO*D}R(HS)aUobIN;!l4vnE;5Qvku*?7e diff --git a/changelog.txt b/changelog.txt index b7ec29b8..6961d4a4 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 OOCalc, Gnumeric and Excel2003XML Readers +- Feature: (MBaker) Added support for cell comments in the OOCalc, Gnumeric and Excel2003XML Readers, and in the Excel5 Reader (for BIFF5-7... BIFF8 Still outstanding) - 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