General: Fix to calculation properties for Excel2007 so that the opening application will only recalculate on load if it's actually required
General: Modified Excel2007 Writer to default preCalculateFormulas to false Note that autosize columns will still recalculate affected formulae internally
This commit is contained in:
parent
555a4ab828
commit
68a0918ceb
|
@ -35,6 +35,17 @@
|
|||
*/
|
||||
class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Pre-calculate formulas
|
||||
* Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
|
||||
* immediately available to MS Excel or other office spreadsheet viewer when opening the file
|
||||
*
|
||||
* Overrides the default TRUE for this specific writer for performance reasons
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_preCalculateFormulas = FALSE;
|
||||
|
||||
/**
|
||||
* Office2003 compatibility
|
||||
*
|
||||
|
|
|
@ -194,10 +194,14 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
|
|||
{
|
||||
$objWriter->startElement('calcPr');
|
||||
|
||||
$objWriter->writeAttribute('calcId', '124519');
|
||||
// Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc
|
||||
// If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit
|
||||
// because the file has changed
|
||||
$objWriter->writeAttribute('calcId', '999999');
|
||||
$objWriter->writeAttribute('calcMode', 'auto');
|
||||
// fullCalcOnLoad isn't needed if we've recalculating for the save
|
||||
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? '0' : '1');
|
||||
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0);
|
||||
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
|
|
@ -107,6 +107,15 @@ echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
|||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
|
||||
//
|
||||
// If we set Pre Calculated Formulas to true then PHPExcel will calculate all formulae in the
|
||||
// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
|
||||
// using functions or features (such as array formulae) that aren't yet supported by the calculation engine
|
||||
// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to
|
||||
// open the file) will need to recalculate values itself to guarantee that the correct results are available.
|
||||
//
|
||||
//$objWriter->setPreCalculateFormulas(true);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
|
|
@ -207,6 +207,15 @@ echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
|||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
|
||||
//
|
||||
// If we set Pre Calculated Formulas to true then PHPExcel will calculate all formulae in the
|
||||
// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
|
||||
// using functions or features (such as array formulae) that aren't yet supported by the calculation engine
|
||||
// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to
|
||||
// open the file) will need to recalculate values itself to guarantee that the correct results are available.
|
||||
//
|
||||
//$objWriter->setPreCalculateFormulas(true);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
|
|
@ -33,6 +33,10 @@ Fixed in develop branch for release v1.8.0:
|
|||
- Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer
|
||||
- General: (cdhutch) Work item 20055 - Remove array_shift in ReferenceHelper::insertNewBefore improves column or row delete speed
|
||||
- General: (MBaker) - Improve stock chart handling and rendering, with help from Swashata Ghosh
|
||||
- General: (MBaker) - Fix to calculation properties for Excel2007 so that the opening application will only recalculate on load
|
||||
if it's actually required
|
||||
- General: (MBaker) - Modified Excel2007 Writer to default preCalculateFormulas to false
|
||||
Note that autosize columns will still recalculate affected formulae internally
|
||||
|
||||
|
||||
Fixed in develop branch for release v1.7.9:
|
||||
|
|
Loading…
Reference in New Issue