Feature: Added support for cell comments in the Gnumeric and Excel2003XML Readers
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@67186 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
5a2830c499
commit
2b4c15b92f
|
@ -91,6 +91,13 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
|||
*/
|
||||
private $_fillColor;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Comment
|
||||
*
|
||||
|
@ -102,6 +109,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
|||
$this->_author = 'Author';
|
||||
$this->_text = new PHPExcel_RichText();
|
||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,6 +261,26 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
|||
return $this->_fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
|
||||
$this->_alignment = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alignment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlignment() {
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
|
@ -268,6 +296,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
|||
. $this->_marginTop
|
||||
. ($this->_visible ? 1 : 0)
|
||||
. $this->_fillColor->getHashCode()
|
||||
. $this->_alignment
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
|
|
@ -554,6 +554,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
|
|||
}
|
||||
|
||||
$columnID = 'A';
|
||||
if (isset($worksheet->Table->Column)) {
|
||||
foreach($worksheet->Table->Column as $columnData) {
|
||||
$columnData_ss = $columnData->attributes($namespaces['ss']);
|
||||
if (isset($columnData_ss['Index'])) {
|
||||
|
@ -566,8 +567,10 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
|
|||
}
|
||||
++$columnID;
|
||||
}
|
||||
}
|
||||
|
||||
$rowID = 1;
|
||||
if (isset($worksheet->Table->Row)) {
|
||||
foreach($worksheet->Table->Row as $rowData) {
|
||||
$rowHasData = false;
|
||||
$row_ss = $rowData->attributes($namespaces['ss']);
|
||||
|
@ -654,6 +657,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasCalculatedValue) {
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
|
||||
|
@ -700,6 +704,24 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
|
|||
$cellIsSet = $rowHasData = true;
|
||||
}
|
||||
|
||||
if (isset($cell->Comment)) {
|
||||
// echo '<b>comment found</b><br />';
|
||||
$commentAttributes = $cell->Comment->attributes($namespaces['ss']);
|
||||
$author = 'unknown';
|
||||
if (isset($commentAttributes->Author)) {
|
||||
$author = (string)$commentAttributes->Author;
|
||||
// echo 'Author: ',$author,'<br />';
|
||||
}
|
||||
$node = $cell->Comment->Data->asXML();
|
||||
// $annotation = str_replace('html:','',substr($node,49,-10));
|
||||
// echo $annotation,'<br />';
|
||||
$annotation = strip_tags($node);
|
||||
// echo 'Annotation: ',$annotation,'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
|
||||
->setAuthor( $author )
|
||||
->setText($this->_parseRichText($annotation) );
|
||||
}
|
||||
|
||||
if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
|
||||
$style = (string) $cell_ss['StyleID'];
|
||||
// echo 'Cell style for '.$columnID.$rowID.' is '.$style.'<br />';
|
||||
|
@ -729,6 +751,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
|
|||
|
||||
++$rowID;
|
||||
}
|
||||
}
|
||||
++$worksheetID;
|
||||
}
|
||||
|
||||
|
@ -736,4 +759,12 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
|
|||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText($is);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -406,6 +406,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
|
|||
if (isset($sheet->PrintInformation->Margins)) {
|
||||
foreach($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) {
|
||||
$marginAttributes = $margin->attributes();
|
||||
$marginSize = 72 / 100; // Default
|
||||
switch($marginAttributes['PrefUnit']) {
|
||||
case 'mm' :
|
||||
$marginSize = intval($marginAttributes['Points']) / 100;
|
||||
|
@ -506,6 +507,14 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
|
|||
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell,$type);
|
||||
}
|
||||
|
||||
if ((!$this->_readDataOnly) && (isset($sheet->Objects))) {
|
||||
foreach($sheet->Objects->children('gnm',TRUE) as $key => $comment) {
|
||||
$commentAttributes = $comment->attributes();
|
||||
$objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound )
|
||||
->setAuthor( (string)$commentAttributes->Author )
|
||||
->setText($this->_parseRichText((string)$commentAttributes->Text) );
|
||||
}
|
||||
}
|
||||
// echo '$maxCol=',$maxCol,'; $maxRow=',$maxRow,'<br />';
|
||||
//
|
||||
foreach($sheet->Styles->StyleRegion as $styleRegion) {
|
||||
|
@ -867,6 +876,14 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
|
|||
return $styleArray;
|
||||
}
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText($is);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private static function _parseGnumericColour($gnmColour) {
|
||||
list($gnmR,$gnmG,$gnmB) = explode(':',$gnmColour);
|
||||
$gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2);
|
||||
|
|
|
@ -632,13 +632,13 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
|||
}
|
||||
|
||||
return md5(
|
||||
$this->getFill()->getHashCode()
|
||||
. $this->getFont()->getHashCode()
|
||||
. $this->getBorders()->getHashCode()
|
||||
. $this->getAlignment()->getHashCode()
|
||||
. $this->getNumberFormat()->getHashCode()
|
||||
$this->_fill->getHashCode()
|
||||
. $this->_font->getHashCode()
|
||||
. $this->_borders->getHashCode()
|
||||
. $this->_alignment->getHashCode()
|
||||
. $this->_numberFormat->getHashCode()
|
||||
. $hashConditionals
|
||||
. $this->getProtection()->getHashCode()
|
||||
. $this->_protection->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -26,11 +26,14 @@
|
|||
Fixed in SVN:
|
||||
- Feature: (MBaker) Provide option to use PCLZip as an alternative to ZipArchive.
|
||||
This allows the writing of Excel2007 files, even without ZipArchive enabled (it does require zlib), or when php_zip is one of the buggy PHP 5.2.6 or 5.2.8 versions
|
||||
It can be enabled using PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
|
||||
Note that it is not yet implemented as an alternative to ZipArchive for those Readers that are extracting from zips
|
||||
- Feature: (MBaker) Work item 14979 - Added listWorksheetNames() method to Readers that support multiple worksheets in a workbook, allowing a user to extract a list of all the worksheet names from a file without parsing/loading the whole file.
|
||||
- Feature: (MBaker) Speed boost and memory reduction in the Worksheet toArray() method.
|
||||
- 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
|
||||
- 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
|
||||
|
|
Loading…
Reference in New Issue