Feature: Added initial support for cell comments in the Excel5 Reader for BIFF8
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@67346 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
5404406884
commit
db2fb8158a
|
@ -334,6 +334,20 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
private $_objs;
|
private $_objs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text Objects. One TXO record corresponds with one entry.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $_textObjects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cell Annotations (BIFF8)
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $_cellNotes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The combined MSODRAWINGGROUP data
|
* The combined MSODRAWINGGROUP data
|
||||||
*
|
*
|
||||||
|
@ -712,12 +726,18 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
// Initialize objs
|
// Initialize objs
|
||||||
$this->_objs = array();
|
$this->_objs = array();
|
||||||
|
|
||||||
|
// Initialize text objs
|
||||||
|
$this->_textObjects = array();
|
||||||
|
|
||||||
// Initialize shared formula parts
|
// Initialize shared formula parts
|
||||||
$this->_sharedFormulaParts = array();
|
$this->_sharedFormulaParts = array();
|
||||||
|
|
||||||
// Initialize shared formulas
|
// Initialize shared formulas
|
||||||
$this->_sharedFormulas = array();
|
$this->_sharedFormulas = array();
|
||||||
|
|
||||||
|
// Initialize cell annotations
|
||||||
|
$this->_cellNotes = array();
|
||||||
|
|
||||||
while ($this->_pos <= $this->_dataSize - 4) {
|
while ($this->_pos <= $this->_dataSize - 4) {
|
||||||
$code = self::_GetInt2d($this->_data, $this->_pos);
|
$code = self::_GetInt2d($this->_data, $this->_pos);
|
||||||
|
|
||||||
|
@ -771,6 +791,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
case self::XLS_Type_RANGEPROTECTION: $this->_readRangeProtection(); break;
|
case self::XLS_Type_RANGEPROTECTION: $this->_readRangeProtection(); break;
|
||||||
case self::XLS_Type_NOTE: $this->_readNote(); break;
|
case self::XLS_Type_NOTE: $this->_readNote(); break;
|
||||||
//case self::XLS_Type_IMDATA: $this->_readImData(); break;
|
//case self::XLS_Type_IMDATA: $this->_readImData(); break;
|
||||||
|
case self::XLS_Type_TXO: $this->_readTextObject(); break;
|
||||||
case self::XLS_Type_CONTINUE: $this->_readContinue(); break;
|
case self::XLS_Type_CONTINUE: $this->_readContinue(); break;
|
||||||
case self::XLS_Type_EOF: $this->_readDefault(); break 2;
|
case self::XLS_Type_EOF: $this->_readDefault(); break 2;
|
||||||
default: $this->_readDefault(); break;
|
default: $this->_readDefault(); break;
|
||||||
|
@ -794,7 +815,9 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
|
|
||||||
// treat OBJ records
|
// treat OBJ records
|
||||||
foreach ($this->_objs as $n => $obj) {
|
foreach ($this->_objs as $n => $obj) {
|
||||||
// echo 'Object ID is ',$n,'<br />';
|
// echo '<b>Object</b> ID is ',$n,'<br />';
|
||||||
|
// var_dump($obj);
|
||||||
|
// echo '<br />';
|
||||||
//
|
//
|
||||||
// the first shape container never has a corresponding OBJ record, hence $n + 1
|
// the first shape container never has a corresponding OBJ record, hence $n + 1
|
||||||
$spContainer = $allSpContainers[$n + 1];
|
$spContainer = $allSpContainers[$n + 1];
|
||||||
|
@ -825,6 +848,9 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
case 0x19:
|
case 0x19:
|
||||||
// Note
|
// Note
|
||||||
// echo 'Cell Annotation Object<br />';
|
// echo 'Cell Annotation Object<br />';
|
||||||
|
$this->_objs[$n]['objTextData'] = $this->_textObjects[$obj['idObjID']-1];
|
||||||
|
$text = $this->_textObjects[$obj['idObjID']-1]['text'];
|
||||||
|
// echo $text,'<br />';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x08:
|
case 0x08:
|
||||||
|
@ -884,6 +910,22 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($this->_cellNotes) > 0) {
|
||||||
|
foreach($this->_cellNotes as $note => $noteDetails) {
|
||||||
|
// echo '<b>Cell annotation ',$note,'</b><br />';
|
||||||
|
// var_dump($noteDetails);
|
||||||
|
// echo '<br />';
|
||||||
|
if (isset($this->_objs[$noteDetails['objectID']-1])) {
|
||||||
|
// var_dump($this->_objs[$noteDetails['objectID']-1]);
|
||||||
|
// echo '<br />';
|
||||||
|
$cellAddress = str_replace('$','',$noteDetails['cellRef']);
|
||||||
|
$this->_phpSheet->getComment( $cellAddress )
|
||||||
|
->setAuthor( $noteDetails['author'] )
|
||||||
|
->setText($this->_parseRichText($this->_objs[$noteDetails['objectID']-1]['objTextData']['text']) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the named ranges (defined names)
|
// add the named ranges (defined names)
|
||||||
|
@ -1359,6 +1401,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
// 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,'<hr />';
|
// echo 'Note Author=',$noteAuthor,'<hr />';
|
||||||
|
//
|
||||||
|
$this->_cellNotes[] = array('cellRef' => $cellAddress,
|
||||||
|
'objectID' => $noteObjID,
|
||||||
|
'author' => $noteAuthor
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$extension = false;
|
$extension = false;
|
||||||
if ($cellAddress == '$B$65536') {
|
if ($cellAddress == '$B$65536') {
|
||||||
|
@ -1378,10 +1425,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
// echo 'Note Text=',$noteText,'<br />';
|
// echo 'Note Text=',$noteText,'<br />';
|
||||||
|
|
||||||
if ($extension) {
|
if ($extension) {
|
||||||
|
// Concatenate this extension with the currently set comment for the cell
|
||||||
$comment = $this->_phpSheet->getComment( $cellAddress );
|
$comment = $this->_phpSheet->getComment( $cellAddress );
|
||||||
$commentText = $comment->getText()->getPlainText();
|
$commentText = $comment->getText()->getPlainText();
|
||||||
$comment->setText($this->_parseRichText($commentText.$noteText) );
|
$comment->setText($this->_parseRichText($commentText.$noteText) );
|
||||||
} else {
|
} else {
|
||||||
|
// Set comment for the cell
|
||||||
$this->_phpSheet->getComment( $cellAddress )
|
$this->_phpSheet->getComment( $cellAddress )
|
||||||
// ->setAuthor( $author )
|
// ->setAuthor( $author )
|
||||||
->setText($this->_parseRichText($noteText) );
|
->setText($this->_parseRichText($noteText) );
|
||||||
|
@ -1390,6 +1439,41 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TEXT Object record contains the text associated with a cell annotation.
|
||||||
|
*/
|
||||||
|
private function _readTextObject()
|
||||||
|
{
|
||||||
|
// echo '<b>Read Text Object</b><br />';
|
||||||
|
$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) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// recordData consists of an array of subrecords looking like this:
|
||||||
|
// grbit: 2 bytes; Option Flags
|
||||||
|
// rot: 2 bytes; rotation
|
||||||
|
// cchText: 2 bytes; length of the text (in the first continue record)
|
||||||
|
// cbRuns: 2 bytes; length of the formatting (in the second continue record)
|
||||||
|
|
||||||
|
$grbitOpts = self::_GetInt2d($recordData, 0);
|
||||||
|
$rot = self::_GetInt2d($recordData, 2);
|
||||||
|
$cchText = self::_GetInt2d($recordData, 10);
|
||||||
|
$cbRuns = self::_GetInt2d($recordData, 12);
|
||||||
|
$text = $this->_getSplicedRecordData();
|
||||||
|
|
||||||
|
$this->_textObjects[] = array( 'text' => substr($text["recordData"],$text["spliceOffsets"][0]+1,$cchText),
|
||||||
|
'format' => substr($text["recordData"],$text["spliceOffsets"][1],$cbRuns),
|
||||||
|
'alignment' => $grbitOpts,
|
||||||
|
'rotation' => $rot
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read BOF
|
* Read BOF
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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, and in the Excel5 Reader (for BIFF5-7... BIFF8 Still outstanding)
|
- Feature: (MBaker) Added support for cell comments in the OOCalc, Gnumeric and Excel2003XML Readers, and in the Excel5 Reader
|
||||||
- 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
|
||||||
|
|
Loading…
Reference in New Issue