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
This commit is contained in:
Mark Baker 2011-01-21 16:41:02 +00:00
parent 9cc2f8d50b
commit 2368c7fbd0
3 changed files with 50 additions and 16 deletions

View File

@ -820,11 +820,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024; $offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024;
$offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256; $offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256;
switch ($obj['type']) { switch ($obj['otObjType']) {
case 0x19: case 0x19:
// Note // Note
// echo 'Comment Object<br />'; // echo 'Cell Annotation Object<br />';
break; break;
case 0x08: case 0x08:
@ -1336,26 +1336,40 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
private function _readNote() private function _readNote()
{ {
// echo 'Read Note<br />'; // echo '<b>Read Cell Annotation</b><br />';
$length = self::_GetInt2d($this->_data, $this->_pos + 2); $length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length); $recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record // move stream pointer to next record
$this->_pos += 4 + $length; $this->_pos += 4 + $length;
if ($this->_readDataOnly || $this->_version != self::XLS_BIFF8) { if ($this->_readDataOnly) {
return; return;
} }
// hexDump($recordData);
//
$cellAddress = $this->_readBIFF8CellAddress(substr($recordData, 0, 4)); $cellAddress = $this->_readBIFF8CellAddress(substr($recordData, 0, 4));
if ($this->_version == self::XLS_BIFF8) {
$noteObjID = self::_GetInt2d($recordData, 6); $noteObjID = self::_GetInt2d($recordData, 6);
$noteAuthor = trim(substr($recordData, 8)); $noteAuthor = trim(substr($recordData, 8));
// echo 'Note Address=',$cellAddress,'<br />'; // echo 'Note Address=',$cellAddress,'<br />';
// echo 'Note Object ID=',$noteObjID,'<br />'; // echo 'Note Object ID=',$noteObjID,'<br />';
// echo 'Note Author=',$noteAuthor,'<br />'; // echo 'Note Author=',$noteAuthor,'<hr />';
} else {
$cellAddress = str_replace('$','',$cellAddress);
// $noteLength = self::_GetInt2d($recordData, 4);
$noteText = trim(substr($recordData, 6));
// echo 'Note Address=',$cellAddress,'<br />';
// echo 'Note Length=',$noteLength,'<br />';
// echo 'Note Text=',$noteText,'<br />';
$this->_phpSheet->getComment( $cellAddress )
// ->setAuthor( $author )
->setText($this->_parseRichText($noteText) );
}
} }
/** /**
@ -3747,16 +3761,28 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
} }
// recordData consists of an array of subrecords looking like this: // recordData consists of an array of subrecords looking like this:
// ft: 2 bytes; id number // ft: 2 bytes; ftCmo type (0x15)
// cb: 2 bytes; size in bytes of following data // 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 // data: var; subrecord data
// for now, we are just interested in the second subrecord containing the object type // 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( $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;
}
} }

View File

@ -33,7 +33,7 @@ Fixed in SVN:
- Feature: (MBaker) Added new rangeToArray() and namedRangeToArray() methods to the PHPExcel_Worksheet object. - 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. 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(). 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 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 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 - Bugfix: (MBaker) Work item 14901 - VLOOKUP choking on parameters in PHPExcel.1.7.5/PHPExcel_Writer_Excel2007