mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 16:56:03 +03:00
Merge changes from the 1.7.9 develop branch since 1.7.9 release
This commit is contained in:
parent
a453d68430
commit
46a5fd4c13
@ -307,9 +307,9 @@ class Calculation_LookupRef {
|
||||
if (strpos($cellAddress,'!') !== false) {
|
||||
list($sheetName, $cellAddress) = explode('!',$cellAddress);
|
||||
$sheetName = trim($sheetName, "'");
|
||||
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
|
||||
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getParent();
|
||||
$pSheet = $pCell->getWorksheet();
|
||||
}
|
||||
|
||||
return Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, false);
|
||||
@ -318,9 +318,9 @@ class Calculation_LookupRef {
|
||||
if (strpos($cellAddress,'!') !== false) {
|
||||
list($sheetName,$cellAddress) = explode('!',$cellAddress);
|
||||
$sheetName = trim($sheetName, "'");
|
||||
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
|
||||
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getParent();
|
||||
$pSheet = $pCell->getWorksheet();
|
||||
}
|
||||
|
||||
return Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, false);
|
||||
@ -412,9 +412,9 @@ class Calculation_LookupRef {
|
||||
}
|
||||
|
||||
if ($sheetName !== null) {
|
||||
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
|
||||
$pSheet = $pCell->getWorksheet()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getParent();
|
||||
$pSheet = $pCell->getWorksheet();
|
||||
}
|
||||
|
||||
return Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
|
||||
|
@ -471,7 +471,7 @@ class Cell
|
||||
/**
|
||||
* Get parent worksheet
|
||||
*
|
||||
* @return PHPExcel\Worksheet
|
||||
* @return PHPExcel\CachedObjectStorage_CacheBase
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->_parent;
|
||||
|
@ -492,6 +492,10 @@ class Reader_Excel2007 extends Reader_Abstract implements Reader_IReader
|
||||
//$numFmt = str_replace('mm', 'i', $numFmt);
|
||||
//$numFmt = str_replace('h', 'H', $numFmt);
|
||||
|
||||
$quotePrefix = false;
|
||||
if (isset($xf["quotePrefix"])) {
|
||||
$quotePrefix = (boolean) $xf["quotePrefix"];
|
||||
}
|
||||
$style = (object) array(
|
||||
"numFmt" => $numFmt,
|
||||
"font" => $xmlStyles->fonts->font[intval($xf["fontId"])],
|
||||
@ -499,6 +503,7 @@ class Reader_Excel2007 extends Reader_Abstract implements Reader_IReader
|
||||
"border" => $xmlStyles->borders->border[intval($xf["borderId"])],
|
||||
"alignment" => $xf->alignment,
|
||||
"protection" => $xf->protection,
|
||||
"quotePrefix" => $quotePrefix,
|
||||
);
|
||||
$styles[] = $style;
|
||||
|
||||
@ -526,6 +531,7 @@ class Reader_Excel2007 extends Reader_Abstract implements Reader_IReader
|
||||
"border" => $xmlStyles->borders->border[intval($xf["borderId"])],
|
||||
"alignment" => $xf->alignment,
|
||||
"protection" => $xf->protection,
|
||||
"quotePrefix" => $quotePrefix,
|
||||
);
|
||||
$cellStyles[] = $cellStyle;
|
||||
|
||||
@ -1848,6 +1854,11 @@ class Reader_Excel2007 extends Reader_Abstract implements Reader_IReader
|
||||
$docStyle->getProtection()->setHidden(Style_Protection::PROTECTION_UNPROTECTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// top-level style settings
|
||||
if (isset($style->quotePrefix)) {
|
||||
$docStyle->setQuotePrefix($style->quotePrefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1562,11 +1562,15 @@ class Reader_Excel5 extends Reader_Abstract implements Reader_IReader
|
||||
private function _readFilepass()
|
||||
{
|
||||
$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
|
||||
$this->_pos += 4 + $length;
|
||||
|
||||
if (!$this->_readDataOnly) {
|
||||
// offset: 0; size: 2; 16-bit hash value of password
|
||||
$password = strtoupper(dechex(self::_GetInt2d($recordData, 0))); // the hashed password
|
||||
}
|
||||
throw new Reader_Exception('Cannot read encrypted file');
|
||||
}
|
||||
|
||||
@ -1829,6 +1833,9 @@ class Reader_Excel5 extends Reader_Abstract implements Reader_IReader
|
||||
case 3:
|
||||
$objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_RIGHT);
|
||||
break;
|
||||
case 4:
|
||||
$objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_FILL);
|
||||
break;
|
||||
case 5:
|
||||
$objStyle->getAlignment()->setHorizontal(Style_Alignment::HORIZONTAL_JUSTIFY);
|
||||
break;
|
||||
|
@ -86,6 +86,13 @@ class Style extends Style_Supervisor implements IComparable
|
||||
*/
|
||||
protected $_protection;
|
||||
|
||||
/**
|
||||
* Use Quote Prefix when displaying in cell editor. Only used for real style.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_quotePrefix = false;
|
||||
|
||||
/**
|
||||
* Index of style in collection. Only used for real style.
|
||||
*
|
||||
@ -158,6 +165,17 @@ class Style extends Style_Supervisor implements IComparable
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build style array from subcomponents
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public function getStyleArray($array)
|
||||
{
|
||||
return array('quotePrefix' => $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
@ -187,7 +205,8 @@ class Style extends Style_Supervisor implements IComparable
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* 'quotePrefix' => true
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
@ -465,6 +484,9 @@ class Style extends Style_Supervisor implements IComparable
|
||||
if (array_key_exists('protection', $pStyles)) {
|
||||
$this->getProtection()->applyFromArray($pStyles['protection']);
|
||||
}
|
||||
if (array_key_exists('quotePrefix', $pStyles)) {
|
||||
$this->_quotePrefix = $pStyles['quotePrefix'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Invalid style array passed.");
|
||||
@ -568,6 +590,38 @@ class Style extends Style_Supervisor implements IComparable
|
||||
return $this->_protection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get quote prefix
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getQuotePrefix()
|
||||
{
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getQuotePrefix();
|
||||
}
|
||||
return $this->_quotePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set quote prefix
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setQuotePrefix($pValue)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = array('quotePrefix' => $pValue);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_quotePrefix = (boolean) $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
@ -588,6 +642,7 @@ class Style extends Style_Supervisor implements IComparable
|
||||
. $this->_numberFormat->getHashCode()
|
||||
. $hashConditionals
|
||||
. $this->_protection->getHashCode()
|
||||
. ($this->_quotePrefix ? 't' : 'f')
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
@ -39,17 +39,20 @@ class Style_Alignment extends Style_Supervisor implements IComparable
|
||||
{
|
||||
/* Horizontal alignment styles */
|
||||
const HORIZONTAL_GENERAL = 'general';
|
||||
const HORIZONTAL_LEFT = 'left';
|
||||
const HORIZONTAL_RIGHT = 'right';
|
||||
const HORIZONTAL_CENTER = 'center';
|
||||
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
|
||||
const HORIZONTAL_LEFT = 'left';
|
||||
const HORIZONTAL_RIGHT = 'right';
|
||||
const HORIZONTAL_CENTER = 'center';
|
||||
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
|
||||
const HORIZONTAL_JUSTIFY = 'justify';
|
||||
const HORIZONTAL_FILL = 'fill';
|
||||
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
|
||||
|
||||
/* Vertical alignment styles */
|
||||
const VERTICAL_BOTTOM = 'bottom';
|
||||
const VERTICAL_TOP = 'top';
|
||||
const VERTICAL_CENTER = 'center';
|
||||
const VERTICAL_JUSTIFY = 'justify';
|
||||
const VERTICAL_BOTTOM = 'bottom';
|
||||
const VERTICAL_TOP = 'top';
|
||||
const VERTICAL_CENTER = 'center';
|
||||
const VERTICAL_JUSTIFY = 'justify';
|
||||
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
|
@ -65,6 +65,13 @@ class Writer_Excel2007 extends Writer_Abstract implements Writer_IWriter
|
||||
*/
|
||||
private $_stringTable = array();
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Style HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_styleHashTable;
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel\Style_Conditional HashTable
|
||||
*
|
||||
@ -117,18 +124,19 @@ class Writer_Excel2007 extends Writer_Abstract implements Writer_IWriter
|
||||
// Assign PHPExcel
|
||||
$this->setPHPExcel($pPHPExcel);
|
||||
|
||||
$writerPartsArray = array( 'stringtable' => __NAMESPACE__ . '\Writer_Excel2007_StringTable',
|
||||
'contenttypes' => __NAMESPACE__ . '\Writer_Excel2007_ContentTypes',
|
||||
'docprops' => __NAMESPACE__ . '\Writer_Excel2007_DocProps',
|
||||
'rels' => __NAMESPACE__ . '\Writer_Excel2007_Rels',
|
||||
'theme' => __NAMESPACE__ . '\Writer_Excel2007_Theme',
|
||||
'style' => __NAMESPACE__ . '\Writer_Excel2007_Style',
|
||||
'workbook' => __NAMESPACE__ . '\Writer_Excel2007_Workbook',
|
||||
'worksheet' => __NAMESPACE__ . '\Writer_Excel2007_Worksheet',
|
||||
'drawing' => __NAMESPACE__ . '\Writer_Excel2007_Drawing',
|
||||
'comments' => __NAMESPACE__ . '\Writer_Excel2007_Comments',
|
||||
'chart' => __NAMESPACE__ . '\Writer_Excel2007_Chart',
|
||||
);
|
||||
$writerPartsArray = array(
|
||||
'stringtable' => __NAMESPACE__ . '\Writer_Excel2007_StringTable',
|
||||
'contenttypes' => __NAMESPACE__ . '\Writer_Excel2007_ContentTypes',
|
||||
'docprops' => __NAMESPACE__ . '\Writer_Excel2007_DocProps',
|
||||
'rels' => __NAMESPACE__ . '\Writer_Excel2007_Rels',
|
||||
'theme' => __NAMESPACE__ . '\Writer_Excel2007_Theme',
|
||||
'style' => __NAMESPACE__ . '\Writer_Excel2007_Style',
|
||||
'workbook' => __NAMESPACE__ . '\Writer_Excel2007_Workbook',
|
||||
'worksheet' => __NAMESPACE__ . '\Writer_Excel2007_Worksheet',
|
||||
'drawing' => __NAMESPACE__ . '\Writer_Excel2007_Drawing',
|
||||
'comments' => __NAMESPACE__ . '\Writer_Excel2007_Comments',
|
||||
'chart' => __NAMESPACE__ . '\Writer_Excel2007_Chart',
|
||||
);
|
||||
|
||||
// Initialise writer parts
|
||||
// and Assign their parent IWriters
|
||||
@ -136,8 +144,9 @@ class Writer_Excel2007 extends Writer_Abstract implements Writer_IWriter
|
||||
$this->_writerParts[$writer] = new $class($this);
|
||||
}
|
||||
|
||||
$hashTablesArray = array( '_stylesConditionalHashTable', '_fillHashTable', '_fontHashTable',
|
||||
'_bordersHashTable', '_numFmtHashTable', '_drawingHashTable'
|
||||
$hashTablesArray = array( '_stylesConditionalHashTable', '_fillHashTable', '_fontHashTable',
|
||||
'_bordersHashTable', '_numFmtHashTable', '_drawingHashTable',
|
||||
'_styleHashTable'
|
||||
);
|
||||
|
||||
// Set HashTable variables
|
||||
@ -193,6 +202,7 @@ class Writer_Excel2007 extends Writer_Abstract implements Writer_IWriter
|
||||
}
|
||||
|
||||
// Create styles dictionaries
|
||||
$this->_styleHashTable->addFromSource( $this->getWriterPart('Style')->allStyles($this->_spreadSheet) );
|
||||
$this->_stylesConditionalHashTable->addFromSource( $this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet) );
|
||||
$this->_fillHashTable->addFromSource( $this->getWriterPart('Style')->allFills($this->_spreadSheet) );
|
||||
$this->_fontHashTable->addFromSource( $this->getWriterPart('Style')->allFonts($this->_spreadSheet) );
|
||||
@ -397,6 +407,15 @@ class Writer_Excel2007 extends Writer_Abstract implements Writer_IWriter
|
||||
return $this->_stringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Style HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getStyleHashTable() {
|
||||
return $this->_styleHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel\Style_Conditional HashTable
|
||||
*
|
||||
|
@ -400,6 +400,9 @@ class Writer_Excel2007_Style extends Writer_Excel2007_WriterPart
|
||||
$objWriter->writeAttribute('xfId', 0);
|
||||
$objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
|
||||
|
||||
if ($pStyle->getQuotePrefix()) {
|
||||
$objWriter->writeAttribute('quotePrefix', 1);
|
||||
}
|
||||
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
|
||||
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
|
||||
} else {
|
||||
|
@ -416,28 +416,29 @@ class Writer_Excel5_Xf
|
||||
* @static array of int
|
||||
*
|
||||
*/
|
||||
private static $_mapFillType = array( Style_Fill::FILL_NONE => 0x00,
|
||||
Style_Fill::FILL_SOLID => 0x01,
|
||||
Style_Fill::FILL_PATTERN_MEDIUMGRAY => 0x02,
|
||||
Style_Fill::FILL_PATTERN_DARKGRAY => 0x03,
|
||||
Style_Fill::FILL_PATTERN_LIGHTGRAY => 0x04,
|
||||
Style_Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05,
|
||||
Style_Fill::FILL_PATTERN_DARKVERTICAL => 0x06,
|
||||
Style_Fill::FILL_PATTERN_DARKDOWN => 0x07,
|
||||
Style_Fill::FILL_PATTERN_DARKUP => 0x08,
|
||||
Style_Fill::FILL_PATTERN_DARKGRID => 0x09,
|
||||
Style_Fill::FILL_PATTERN_DARKTRELLIS => 0x0A,
|
||||
Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B,
|
||||
Style_Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C,
|
||||
Style_Fill::FILL_PATTERN_LIGHTDOWN => 0x0D,
|
||||
Style_Fill::FILL_PATTERN_LIGHTUP => 0x0E,
|
||||
Style_Fill::FILL_PATTERN_LIGHTGRID => 0x0F,
|
||||
Style_Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
|
||||
Style_Fill::FILL_PATTERN_GRAY125 => 0x11,
|
||||
Style_Fill::FILL_PATTERN_GRAY0625 => 0x12,
|
||||
Style_Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
|
||||
Style_Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
|
||||
);
|
||||
private static $_mapFillType = array(
|
||||
Style_Fill::FILL_NONE => 0x00,
|
||||
Style_Fill::FILL_SOLID => 0x01,
|
||||
Style_Fill::FILL_PATTERN_MEDIUMGRAY => 0x02,
|
||||
Style_Fill::FILL_PATTERN_DARKGRAY => 0x03,
|
||||
Style_Fill::FILL_PATTERN_LIGHTGRAY => 0x04,
|
||||
Style_Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05,
|
||||
Style_Fill::FILL_PATTERN_DARKVERTICAL => 0x06,
|
||||
Style_Fill::FILL_PATTERN_DARKDOWN => 0x07,
|
||||
Style_Fill::FILL_PATTERN_DARKUP => 0x08,
|
||||
Style_Fill::FILL_PATTERN_DARKGRID => 0x09,
|
||||
Style_Fill::FILL_PATTERN_DARKTRELLIS => 0x0A,
|
||||
Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B,
|
||||
Style_Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C,
|
||||
Style_Fill::FILL_PATTERN_LIGHTDOWN => 0x0D,
|
||||
Style_Fill::FILL_PATTERN_LIGHTUP => 0x0E,
|
||||
Style_Fill::FILL_PATTERN_LIGHTGRID => 0x0F,
|
||||
Style_Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
|
||||
Style_Fill::FILL_PATTERN_GRAY125 => 0x11,
|
||||
Style_Fill::FILL_PATTERN_GRAY0625 => 0x12,
|
||||
Style_Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
|
||||
Style_Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
|
||||
);
|
||||
/**
|
||||
* Map fill type
|
||||
*
|
||||
@ -455,13 +456,16 @@ class Writer_Excel5_Xf
|
||||
* @static array of int
|
||||
*
|
||||
*/
|
||||
private static $_mapHAlign = array( Style_Alignment::HORIZONTAL_GENERAL => 0,
|
||||
Style_Alignment::HORIZONTAL_LEFT => 1,
|
||||
Style_Alignment::HORIZONTAL_CENTER => 2,
|
||||
Style_Alignment::HORIZONTAL_RIGHT => 3,
|
||||
Style_Alignment::HORIZONTAL_JUSTIFY => 5,
|
||||
Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6,
|
||||
);
|
||||
private static $_mapHAlign = array(
|
||||
Style_Alignment::HORIZONTAL_GENERAL => 0,
|
||||
Style_Alignment::HORIZONTAL_LEFT => 1,
|
||||
Style_Alignment::HORIZONTAL_CENTER => 2,
|
||||
Style_Alignment::HORIZONTAL_RIGHT => 3,
|
||||
Style_Alignment::HORIZONTAL_FILL => 4,
|
||||
Style_Alignment::HORIZONTAL_JUSTIFY => 5,
|
||||
Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6,
|
||||
);
|
||||
|
||||
/**
|
||||
* Map to BIFF2-BIFF8 codes for horizontal alignment
|
||||
*
|
||||
|
@ -34,9 +34,8 @@ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
/** Include PHPExcel Bootstrap */
|
||||
require_once '../Classes/Bootstrap.php';
|
||||
|
||||
/*
|
||||
After doing some test, I've got these results benchmarked
|
||||
@ -52,9 +51,9 @@ for writing to Excel2007:
|
||||
15000 465
|
||||
*/
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new PHPExcel();
|
||||
// Create new PHPExcel Workbook object
|
||||
echo date('H:i:s') , " Create new PHPExcel Workbook object" , EOL;
|
||||
$objPHPExcel = new PHPExcel\Workbook();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set properties" , EOL;
|
||||
@ -117,7 +116,7 @@ $objPHPExcel->setActiveSheetIndex(0);
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter = PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
Loading…
Reference in New Issue
Block a user