upgrade to PHPExcel 1.7.2

This commit is contained in:
Dieter Adriaenssens
2010-05-02 21:01:53 +02:00
parent 798def6e45
commit b90a1b496b
118 changed files with 9154 additions and 4035 deletions

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter {
/**

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -94,7 +94,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Comments.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -67,7 +67,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_WriterPart
{
@@ -107,14 +107,14 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
$objWriter->startElement('comments');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
// Loop trough authors
// Loop through authors
$objWriter->startElement('authors');
foreach ($authors as $author => $index) {
$objWriter->writeElement('author', $author);
}
$objWriter->endElement();
// Loop trough comments
// Loop through comments
$objWriter->startElement('commentList');
foreach ($comments as $key => $value) {
$this->_writeComment($objWriter, $key, $value, $authors);
@@ -212,7 +212,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
$objWriter->endElement();
// Loop trough comments
// Loop through comments
foreach ($comments as $key => $value) {
$this->_writeVMLComment($objWriter, $key, $value);
}

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -55,7 +55,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_WriterPart
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -70,7 +70,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_WriterPart
{
@@ -99,7 +99,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
$objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
// Loop trough images and write drawings
// Loop through images and write drawings
$i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
@@ -469,7 +469,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
$objWriter->endElement();
// Loop trough images
// Loop through images
foreach ($images as $key => $value) {
$this->_writeVMLHeaderFooterImage($objWriter, $key, $value);
}
@@ -535,10 +535,10 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
// Get an array of all drawings
$aDrawings = array();
// Loop trough PHPExcel
// Loop through PHPExcel
$sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) {
// Loop trough images and add to array
// Loop through images and add to array
$iterator = $pPHPExcel->getSheet($i)->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
$aDrawings[] = $iterator->current();

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -55,7 +55,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPart
{
@@ -219,13 +219,13 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
// Write hyperlink relationships?
$i = 1;
foreach ($pWorksheet->getCellCollection() as $cell) {
if ($cell->hasHyperlink() && !$cell->getHyperlink()->isInternal()) {
foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
if (!$hyperlink->isInternal()) {
$this->_writeRelationship(
$objWriter,
'_hyperlink_' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
$cell->getHyperlink()->getUrl(),
$hyperlink->getUrl(),
'External'
);
@@ -292,7 +292,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Loop trough images and write relationships
// Loop through images and write relationships
$i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
@@ -341,7 +341,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Loop trough images and write relationships
// Loop through images and write relationships
foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
// Write relationship for image drawing
$this->_writeRelationship(

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -55,7 +55,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_WriterPart
{
@@ -83,7 +83,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// Fill index array
$aFlippedStringTable = $this->flipStringTable($aStringTable);
// Loop trough cells
// Loop through cells
$cellCollection = $pSheet->getCellCollection();
foreach ($cellCollection as $cell) {
if (!is_object($cell->getValue()) &&
@@ -137,7 +137,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('uniqueCount', count($pStringTable));
// Loop trough string table
// Loop through string table
foreach ($pStringTable as $textElement) {
$objWriter->startElement('si');
@@ -174,7 +174,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
*/
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null)
{
// Loop trough rich text elements
// Loop through rich text elements
$elements = $pRichText->getRichTextElements();
foreach ($elements as $element) {
// r
@@ -237,7 +237,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// t
$objWriter->startElement('t');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRaw(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($element->getText()) ));
$objWriter->writeRaw(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
$objWriter->endElement();
$objWriter->endElement();
@@ -254,7 +254,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// Return value
$returnValue = array();
// Loop trough stringtable and add flipped items to $returnValue
// Loop through stringtable and add flipped items to $returnValue
foreach ($stringTable as $key => $value) {
if (! $value instanceof PHPExcel_RichText) {
$returnValue[$value] = $key;

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -79,7 +79,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPart
{
@@ -396,6 +396,10 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('diagonalUp', 'false');
$objWriter->writeAttribute('diagonalDown', 'true');
break;
case PHPExcel_Style_Borders::DIAGONAL_BOTH:
$objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'true');
break;
}
// BorderPr

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPart
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -58,7 +58,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_WriterPart
{
@@ -244,7 +244,8 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$objWriter,
$pPHPExcel->getSheet($i)->getTitle(),
($i + 1),
($i + 1 + 3)
($i + 1 + 3),
$pPHPExcel->getSheet($i)->getSheetState()
);
}
@@ -258,15 +259,19 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
* @param string $pSheetname Sheet name
* @param int $pSheetId Sheet id
* @param int $pRelId Relationship ID
* @param string $sheetState Sheet state (visible, hidden, veryHidden)
* @throws Exception
*/
private function _writeSheet(PHPExcel_Shared_XMLWriter $objWriter = null, $pSheetname = '', $pSheetId = 1, $pRelId = 1)
private function _writeSheet(PHPExcel_Shared_XMLWriter $objWriter = null, $pSheetname = '', $pSheetId = 1, $pRelId = 1, $sheetState = 'visible')
{
if ($pSheetname != '') {
// Write sheet
$objWriter->startElement('sheet');
$objWriter->writeAttribute('name', $pSheetname);
$objWriter->writeAttribute('sheetId', $pSheetId);
if ($sheetState != 'visible' && $sheetState != '') {
$objWriter->writeAttribute('state', $sheetState);
}
$objWriter->writeAttribute('r:id', 'rId' . $pRelId);
$objWriter->endElement();
} else {
@@ -449,11 +454,15 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
// Print area
$printArea = PHPExcel_Cell::splitRange($pSheet->getPageSetup()->getPrintArea());
$printArea = $printArea[0];
$printArea[0] = PHPExcel_Cell::absoluteCoordinate($printArea[0]);
$printArea[1] = PHPExcel_Cell::absoluteCoordinate($printArea[1]);
$objWriter->writeRaw('\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printArea));
$chunks = array();
foreach ($printArea as $printAreaRect) {
$printAreaRect[0] = PHPExcel_Cell::absoluteCoordinate($printAreaRect[0]);
$printAreaRect[1] = PHPExcel_Cell::absoluteCoordinate($printAreaRect[1]);
$chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect);
}
$objWriter->writeRaw(implode(',', $chunks));
$objWriter->endElement();
}

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -73,7 +73,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_WriterPart
{
@@ -190,6 +190,13 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->startElement('sheetPr');
//$objWriter->writeAttribute('codeName', $pSheet->getTitle());
// tabColor
if ($pSheet->isTabColorSet()) {
$objWriter->startElement('tabColor');
$objWriter->writeAttribute('rgb', $pSheet->getTabColor()->getARGB());
$objWriter->endElement();
}
// outlinePr
$objWriter->startElement('outlinePr');
$objWriter->writeAttribute('summaryBelow', ($pSheet->getShowSummaryBelow() ? '1' : '0'));
@@ -197,7 +204,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->endElement();
// pageSetUpPr
if (!is_null($pSheet->getPageSetup()->getFitToHeight()) || !is_null($pSheet->getPageSetup()->getFitToWidth())) {
if ($pSheet->getPageSetup()->getFitToPage()) {
$objWriter->startElement('pageSetUpPr');
$objWriter->writeAttribute('fitToPage', '1');
$objWriter->endElement();
@@ -286,8 +293,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Selection
$objWriter->startElement('selection');
$objWriter->writeAttribute('activeCell', $pSheet->getSelectedCell());
$objWriter->writeAttribute('sqref', $pSheet->getSelectedCell());
$objWriter->writeAttribute('activeCell', $pSheet->getActiveCell());
$objWriter->writeAttribute('sqref', $pSheet->getSelectedCells());
$objWriter->endElement();
$objWriter->endElement();
@@ -351,66 +358,59 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
{
// cols
$objWriter->startElement('cols');
if (count($pSheet->getColumnDimensions()) > 0) {
$objWriter->startElement('cols');
// Check if there is at least one column dimension specified. If not, create one.
if (count($pSheet->getColumnDimensions()) == 0) {
if ($pSheet->getDefaultColumnDimension()->getWidth() >= 0) {
$pSheet->getColumnDimension('A')->setWidth($pSheet->getDefaultColumnDimension()->getWidth());
} else {
$pSheet->getColumnDimension('A')->setWidth(9.10);
}
}
$pSheet->calculateColumnWidths();
$pSheet->calculateColumnWidths();
// Loop through column dimensions
foreach ($pSheet->getColumnDimensions() as $colDimension) {
// col
$objWriter->startElement('col');
$objWriter->writeAttribute('min', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
$objWriter->writeAttribute('max', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
// Loop trough column dimensions
foreach ($pSheet->getColumnDimensions() as $colDimension) {
// col
$objWriter->startElement('col');
$objWriter->writeAttribute('min', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
$objWriter->writeAttribute('max', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
if ($colDimension->getWidth() < 0) {
// No width set, apply default of 10
$objWriter->writeAttribute('width', '9.10');
} else {
// Width set
$objWriter->writeAttribute('width', PHPExcel_Shared_String::FormatNumber($colDimension->getWidth()));
}
if ($colDimension->getWidth() < 0) {
// No width set, apply default of 10
$objWriter->writeAttribute('width', '9.10');
} else {
// Width set
$objWriter->writeAttribute('width', PHPExcel_Shared_String::FormatNumber($colDimension->getWidth()));
// Column visibility
if ($colDimension->getVisible() == false) {
$objWriter->writeAttribute('hidden', 'true');
}
// Auto size?
if ($colDimension->getAutoSize()) {
$objWriter->writeAttribute('bestFit', 'true');
}
// Custom width?
if ($colDimension->getWidth() != $pSheet->getDefaultColumnDimension()->getWidth()) {
$objWriter->writeAttribute('customWidth', 'true');
}
// Collapsed
if ($colDimension->getCollapsed() == true) {
$objWriter->writeAttribute('collapsed', 'true');
}
// Outline level
if ($colDimension->getOutlineLevel() > 0) {
$objWriter->writeAttribute('outlineLevel', $colDimension->getOutlineLevel());
}
// Style
$objWriter->writeAttribute('style', $colDimension->getXfIndex());
$objWriter->endElement();
}
// Column visibility
if ($colDimension->getVisible() == false) {
$objWriter->writeAttribute('hidden', 'true');
}
// Auto size?
if ($colDimension->getAutoSize()) {
$objWriter->writeAttribute('bestFit', 'true');
}
// Custom width?
if ($colDimension->getWidth() != $pSheet->getDefaultColumnDimension()->getWidth()) {
$objWriter->writeAttribute('customWidth', 'true');
}
// Collapsed
if ($colDimension->getCollapsed() == true) {
$objWriter->writeAttribute('collapsed', 'true');
}
// Outline level
if ($colDimension->getOutlineLevel() > 0) {
$objWriter->writeAttribute('outlineLevel', $colDimension->getOutlineLevel());
}
// Style
$objWriter->writeAttribute('style', 0);
$objWriter->endElement();
}
$objWriter->endElement();
$objWriter->endElement();
}
}
/**
@@ -460,7 +460,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Conditional id
$id = 1;
// Loop trough styles in the current worksheet
// Loop through styles in the current worksheet
foreach ($pSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) {
foreach ($conditionalStyles as $conditional) {
// WHY was this again?
@@ -491,7 +491,23 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('text', $conditional->getText());
}
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BEGINSWITH
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_ENDSWITH
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_NOTCONTAINS
&& !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) {
foreach ($conditional->getConditions() as $formula) {
@@ -517,20 +533,15 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
*/
private function _writeDataValidations(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
{
// Build a temporary array of datavalidation objects
$aDataValidations = array();
foreach ($pSheet->getCellCollection() as $cell) {
if ($cell->hasDataValidation()) {
$aDataValidations[] = $cell->getDataValidation();
}
}
// Datavalidation collection
$dataValidationCollection = $pSheet->getDataValidationCollection();
// Write data validations?
if (count($aDataValidations) > 0) {
if (count($dataValidationCollection) > 0) {
$objWriter->startElement('dataValidations');
$objWriter->writeAttribute('count', count($aDataValidations));
$objWriter->writeAttribute('count', count($dataValidationCollection));
foreach ($aDataValidations as $dv) {
foreach ($dataValidationCollection as $coordinate => $dv) {
$objWriter->startElement('dataValidation');
if ($dv->getType() != '') {
@@ -563,7 +574,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('prompt', $dv->getPrompt());
}
$objWriter->writeAttribute('sqref', $dv->getParent()->getCoordinate());
$objWriter->writeAttribute('sqref', $coordinate);
if ($dv->getFormula1() !== '') {
$objWriter->writeElement('formula1', $dv->getFormula1());
@@ -588,25 +599,20 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
*/
private function _writeHyperlinks(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
{
// Build a temporary array of hyperlink objects
$aHyperlinks = array();
foreach ($pSheet->getCellCollection() as $cell) {
if ($cell->hasHyperlink()) {
$aHyperlinks[] = $cell->getHyperlink();
}
}
// Hyperlink collection
$hyperlinkCollection = $pSheet->getHyperlinkCollection();
// Relation ID
$relationId = 1;
// Write hyperlinks?
if (count($aHyperlinks) > 0) {
if (count($hyperlinkCollection) > 0) {
$objWriter->startElement('hyperlinks');
foreach ($aHyperlinks as $hyperlink) {
foreach ($hyperlinkCollection as $coordinate => $hyperlink) {
$objWriter->startElement('hyperlink');
$objWriter->writeAttribute('ref', $hyperlink->getParent()->getCoordinate());
$objWriter->writeAttribute('ref', $coordinate);
if (!$hyperlink->isInternal()) {
$objWriter->writeAttribute('r:id', 'rId_hyperlink_' . $relationId);
++$relationId;
@@ -755,17 +761,21 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('orientation', $pSheet->getPageSetup()->getOrientation());
if (!is_null($pSheet->getPageSetup()->getScale())) {
$objWriter->writeAttribute('scale', $pSheet->getPageSetup()->getScale());
$objWriter->writeAttribute('scale', $pSheet->getPageSetup()->getScale());
}
if (!is_null($pSheet->getPageSetup()->getFitToHeight())) {
$objWriter->writeAttribute('fitToHeight', $pSheet->getPageSetup()->getFitToHeight());
$objWriter->writeAttribute('fitToHeight', $pSheet->getPageSetup()->getFitToHeight());
} else {
$objWriter->writeAttribute('fitToHeight', '0');
$objWriter->writeAttribute('fitToHeight', '0');
}
if (!is_null($pSheet->getPageSetup()->getFitToWidth())) {
$objWriter->writeAttribute('fitToWidth', $pSheet->getPageSetup()->getFitToWidth());
$objWriter->writeAttribute('fitToWidth', $pSheet->getPageSetup()->getFitToWidth());
} else {
$objWriter->writeAttribute('fitToWidth', '0');
$objWriter->writeAttribute('fitToWidth', '0');
}
if (!is_null($pSheet->getPageSetup()->getFirstPageNumber())) {
$objWriter->writeAttribute('firstPageNumber', $pSheet->getPageSetup()->getFirstPageNumber());
$objWriter->writeAttribute('useFirstPageNumber', '1');
}
$objWriter->endElement();
@@ -876,7 +886,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Highest row number
$highestRow = $pSheet->getHighestRow();
// Loop trough cells
// Loop through cells
$cellCollection = $pSheet->getCellCollection();
$cellsByRow = array();
@@ -887,13 +897,14 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
for ($currentRow = 1; $currentRow <= $highestRow; ++$currentRow) {
// Get row dimension
$rowDimension = $pSheet->getRowDimension($currentRow);
// Write current row?
$writeCurrentRow = isset($cellsByRow[$currentRow]) ||
$rowDimension->getRowHeight() >= 0 ||
$rowDimension->getVisible() == false ||
$rowDimension->getCollapsed() == true ||
$rowDimension->getOutlineLevel() > 0;
$rowDimension->getOutlineLevel() > 0 ||
$rowDimension->getXfIndex() !== null;
if ($writeCurrentRow) {
// Start a new row
@@ -922,6 +933,12 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('outlineLevel', $rowDimension->getOutlineLevel());
}
// Style
if ($rowDimension->getXfIndex() !== null) {
$objWriter->writeAttribute('s', $rowDimension->getXfIndex());
$objWriter->writeAttribute('customFormat', '1');
}
// Write cells
if (isset($cellsByRow[$currentRow])) {
foreach($cellsByRow[$currentRow] as $cell) {

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel2007
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_Writer_Excel2007_WriterPart
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -43,6 +43,9 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_HashTable */
require_once PHPEXCEL_ROOT . 'PHPExcel/HashTable.php';
/** PHPExcel_Shared_File */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
/** PHPExcel_Shared_OLE_PPS_Root */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_Root.php';
@@ -61,10 +64,17 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Workbook.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
{
/**
* Pre-calculate formulas
*
* @var boolean
*/
private $_preCalculateFormulas;
/**
* PHPExcel object
*
@@ -107,6 +117,13 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
*/
private $_str_table;
/**
* Color cache. Mapping between RGB value and color index.
*
* @var array
*/
private $_colors;
/**
* Formula parser
*
@@ -121,9 +138,10 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
* @param PHPExcel $phpExcel PHPExcel object
*/
public function __construct(PHPExcel $phpExcel) {
$this->_preCalculateFormulas = true;
$this->_phpExcel = $phpExcel;
$this->_BIFF_version = 0x0600;
$this->_tempDir = '';
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
$this->_str_total = 0;
$this->_str_unique = 0;
@@ -151,9 +169,12 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
// initialize colors array
$this->_colors = array();
// Initialise workbook writer
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version,
$this->_str_total, $this->_str_unique, $this->_str_table, $this->_parser, $this->_tempDir);
$this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_tempDir);
// Initialise worksheet writers
$countSheets = count($this->_phpExcel->getAllSheets());
@@ -162,8 +183,9 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$writerWorksheet = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version,
$this->_str_total, $this->_str_unique,
$this->_str_table,
$this->_str_table, $this->_colors,
$this->_parser, $this->_tempDir,
$this->_preCalculateFormulas,
$phpSheet);
$this->_writerWorksheets[$i] = $writerWorksheet;
}
@@ -248,4 +270,22 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
return $this;
}
/**
* Get Pre-Calculate Formulas
*
* @return boolean
*/
public function getPreCalculateFormulas() {
return $this->_preCalculateFormulas;
}
/**
* Set Pre-Calculate Formulas
*
* @param boolean $pValue Pre-Calculate Formulas?
*/
public function setPreCalculateFormulas($pValue = true) {
$this->_preCalculateFormulas = $pValue;
}
}

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_BIFFwriter (used as the base for this class):
@@ -65,7 +65,7 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_BIFFwriter
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Escher
{
@@ -395,7 +395,7 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length);
$data .= $header . pack('VV', $this->_object->getSpId(), $this->_object->getSpgr() ? 0x0005 : 0xA000);
$data .= $header . pack('VV', $this->_object->getSpId(), $this->_object->getSpgr() ? 0x0005 : 0x0A00);
// the options
@@ -447,7 +447,7 @@ class PHPExcel_Writer_Excel5_Escher
// end offsetY
$endOffsetY = $this->_object->getEndOffsetY();
$clientAnchorData = pack('vvvvvvvvv', 0x00,
$clientAnchorData = pack('vvvvvvvvv', 0x02,
$c1, $startOffsetX, $r1, $startOffsetY,
$c2, $endOffsetX, $r2, $endOffsetY);

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -46,7 +46,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Font
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Parser (used as the base for this class):
@@ -70,7 +70,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/BIFFwriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Parser
{
@@ -533,12 +533,12 @@ class PHPExcel_Writer_Excel5_Parser
} elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/',$token)) {
return $this->_convertRef2d($token);
// match external references like Sheet1!A1 or Sheet1:Sheet2!A1
} elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) {
// match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
} elseif (preg_match("/^\w+(\:\w+)?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
return $this->_convertRef3d($token);
// match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1
} elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) {
// match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
} elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
return $this->_convertRef3d($token);
// match ranges like A1:B2
@@ -549,12 +549,12 @@ class PHPExcel_Writer_Excel5_Parser
} elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) {
return $this->_convertRange2d($token);
// match external ranges like Sheet1!A1 or Sheet1:Sheet2!A1:B2
} elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) {
// match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
} elseif (preg_match("/^\w+(\:\w+)?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
return $this->_convertRange3d($token);
// match external ranges like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2
} elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) {
// match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
} elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
return $this->_convertRange3d($token);
// operators (including parentheses)
@@ -652,9 +652,9 @@ class PHPExcel_Writer_Excel5_Parser
// TODO: possible class value 0,1,2 check Formula.pm
// Split the range into 2 cell refs
if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) {
list($cell1, $cell2) = split(':', $range);
list($cell1, $cell2) = explode(':', $range);
} elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) {
list($cell1, $cell2) = split('\.\.', $range);
list($cell1, $cell2) = explode('..', $range);
} else {
// TODO: use real error codes
@@ -694,7 +694,7 @@ class PHPExcel_Writer_Excel5_Parser
$class = 2; // as far as I know, this is magick.
// Split the ref at the ! symbol
list($ext_ref, $range) = split('!', $token);
list($ext_ref, $range) = explode('!', $token);
// Convert the external reference part (different for BIFF8)
if ($this->_BIFF_version == 0x0500) {
@@ -704,10 +704,10 @@ class PHPExcel_Writer_Excel5_Parser
}
// Split the range into 2 cell refs
list($cell1, $cell2) = split(':', $range);
list($cell1, $cell2) = explode(':', $range);
// Convert the cell references
if (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/", $cell1)) {
if (preg_match("/^(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\d+)$/", $cell1)) {
$cell_array1 = $this->_cellToPackedRowcol($cell1);
list($row1, $col1) = $cell_array1;
$cell_array2 = $this->_cellToPackedRowcol($cell2);
@@ -773,7 +773,7 @@ class PHPExcel_Writer_Excel5_Parser
$class = 2; // as far as I know, this is magick.
// Split the ref at the ! symbol
list($ext_ref, $cell) = split('!', $cell);
list($ext_ref, $cell) = explode('!', $cell);
// Convert the external reference part (different for BIFF8)
if ($this->_BIFF_version == 0x0500) {
@@ -814,7 +814,7 @@ class PHPExcel_Writer_Excel5_Parser
// Check if there is a sheet range eg., Sheet1:Sheet2.
if (preg_match("/:/", $ext_ref)) {
list($sheet_name1, $sheet_name2) = split(':', $ext_ref);
list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);
$sheet1 = $this->_getSheetIndex($sheet_name1);
if ($sheet1 == -1) {
@@ -859,7 +859,7 @@ class PHPExcel_Writer_Excel5_Parser
// Check if there is a sheet range eg., Sheet1:Sheet2.
if (preg_match("/:/", $ext_ref)) {
list($sheet_name1, $sheet_name2) = split(':', $ext_ref);
list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);
$sheet1 = $this->_getSheetIndex($sheet_name1);
if ($sheet1 == -1) {
@@ -1158,47 +1158,47 @@ class PHPExcel_Writer_Excel5_Parser
default:
// if it's a reference
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
!ereg("[0-9]",$this->_lookahead) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.') and
($this->_lookahead != '!'))
{
return $token;
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)
elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead) and
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
elseif (preg_match("/^\w+(\:\w+)?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return $token;
}
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1)
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead) and
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return $token;
}
// if it's a range (A1:A2)
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead))
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// if it's a range (A1..A2)
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead))
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2
elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead))
// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
elseif (preg_match("/^\w+(\:\w+)?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
!ereg("[0-9]",$this->_lookahead))
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
@@ -1210,12 +1210,12 @@ class PHPExcel_Writer_Excel5_Parser
return $token;
}
// If it's a string (of maximum 255 characters)
elseif (ereg("^\"[^\"]{0,255}\"$",$token))
elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token))
{
return $token;
}
// if it's a function call
elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "("))
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
{
return $token;
}
@@ -1291,7 +1291,7 @@ class PHPExcel_Writer_Excel5_Parser
function _expression()
{
// If it's a string return a string node
if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) {
if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) {
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
@@ -1388,21 +1388,21 @@ class PHPExcel_Writer_Excel5_Parser
$this->_advance();
return $result;
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)
elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$this->_current_token))
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
elseif (preg_match("/^\w+(\:\w+)?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1)
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$this->_current_token))
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// if it's a range
// if it's a range A1:B2 or $A$1:$B$2
elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or
preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token))
{
@@ -1410,17 +1410,21 @@ class PHPExcel_Writer_Excel5_Parser
$this->_advance();
return $result;
}
// If it's an external range (Sheet1!A1 or Sheet1!A1:B2)
elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$this->_current_token))
// If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2)
elseif (preg_match("/^\w+(\:\w+)?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$this->_current_token))
{
$result = $this->_current_token;
// must be an error?
//$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// If it's an external range ('Sheet1'!A1 or 'Sheet1'!A1:B2)
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$this->_current_token))
// If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2)
elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$this->_current_token))
{
$result = $this->_current_token;
// must be an error?
//$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
@@ -1431,7 +1435,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result;
}
// if it's a function call
elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token))
{
$result = $this->_func();
return $result;

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Workbook (used as the base for this class):
@@ -90,6 +90,9 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContaine
/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Writer_Excel5_Xf */
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Xf.php';
@@ -111,7 +114,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Escher.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
{
@@ -165,11 +168,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/
private $_phpExcel;
/**
* Color cache
*/
private $_colors = array();
/**
* Fonts writers
*
@@ -233,6 +231,11 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/
private $_str_table;
/**
* Color cache
*/
private $_colors;
/**
* Class constructor
@@ -246,7 +249,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/
public function __construct(PHPExcel $phpExcel = null, $BIFF_version = 0x0600,
&$str_total,
&$str_unique, &$str_table, $parser, $tempDir = ''
&$str_unique, &$str_table, &$colors, $parser, $tempDir = ''
)
{
// It needs to call its parent's constructor explicitly
@@ -261,6 +264,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_str_total = &$str_total;
$this->_str_unique = &$str_unique;
$this->_str_table = &$str_table;
$this->_colors = &$colors;
$this->_setPaletteXl97();
$this->_tmp_dir = $tempDir;
@@ -287,6 +291,18 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_parser->_references[] = $ref; // Register reference with parser
}
}
// Build color cache
// Sheet tab colors?
$countSheets = count($phpExcel->getAllSheets());
for ($i = 0; $i < $countSheets; ++$i) {
$phpSheet = $phpExcel->getSheet($i);
if ($phpSheet->isTabColorSet()) {
$this->_addColor($phpSheet->getTabColor()->getRGB());
}
}
}
/**
@@ -302,13 +318,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$xfWriter->setBIFFVersion($this->_BIFF_version);
$xfWriter->setIsStyleXf($isStyleXf);
$xfWriter->setFgColor($this->_addColor($style->getFill()->getStartColor()->getRGB()));
$xfWriter->setBgColor($this->_addColor($style->getFill()->getEndColor()->getRGB()));
$xfWriter->setBottomColor($this->_addColor($style->getBorders()->getBottom()->getColor()->getRGB()));
$xfWriter->setTopColor($this->_addColor($style->getBorders()->getTop()->getColor()->getRGB()));
$xfWriter->setRightColor($this->_addColor($style->getBorders()->getRight()->getColor()->getRGB()));
$xfWriter->setLeftColor($this->_addColor($style->getBorders()->getLeft()->getColor()->getRGB()));
// Add the font if not already added
$fontHashCode = $style->getFont()->getHashCode();
@@ -329,6 +338,15 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Assign the font index to the xf record
$xfWriter->setFontIndex($fontIndex);
// Background colors, best to treat these after the font so black will come after white in custom palette
$xfWriter->setFgColor($this->_addColor($style->getFill()->getStartColor()->getRGB()));
$xfWriter->setBgColor($this->_addColor($style->getFill()->getEndColor()->getRGB()));
$xfWriter->setBottomColor($this->_addColor($style->getBorders()->getBottom()->getColor()->getRGB()));
$xfWriter->setTopColor($this->_addColor($style->getBorders()->getTop()->getColor()->getRGB()));
$xfWriter->setRightColor($this->_addColor($style->getBorders()->getRight()->getColor()->getRGB()));
$xfWriter->setLeftColor($this->_addColor($style->getBorders()->getLeft()->getColor()->getRGB()));
$xfWriter->setDiagColor($this->_addColor($style->getBorders()->getDiagonal()->getColor()->getRGB()));
// Add the number format if it is not a built-in one and not already added
if ($style->getNumberFormat()->getBuiltInFormatCode() === false) {
$numberFormatHashCode = $style->getNumberFormat()->getHashCode();
@@ -509,7 +527,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Add part 2 of the Workbook globals, the SHEET records
$this->_calcSheetOffsets();
for ($i = 0; $i < $total_worksheets; ++$i) {
$this->_storeBoundsheet($this->_phpExcel->getSheet($i)->getTitle(), $this->_worksheetOffsets[$i]);
$this->_storeBoundsheet($this->_phpExcel->getSheet($i), $this->_worksheetOffsets[$i]);
}
// Add part 3 of the Workbook globals
@@ -717,6 +735,34 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
{
$chunk = '';
// Named ranges
if (count($this->_phpExcel->getNamedRanges()) > 0) {
// Loop named ranges
$namedRanges = $this->_phpExcel->getNamedRanges();
foreach ($namedRanges as $namedRange) {
// Create absolute coordinate
$range = PHPExcel_Cell::splitRange($namedRange->getRange());
for ($i = 0; $i < count($range); $i++) {
$range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteCoordinate($range[$i][0]);
if (isset($range[$i][1])) {
$range[$i][1] = PHPExcel_Cell::absoluteCoordinate($range[$i][1]);
}
}
$range = PHPExcel_Cell::buildRange($range); // e.g. Sheet1!$A$1:$B$2
// parse formula
try {
$error = $this->_parser->parse($range);
$formulaData = $this->_parser->toReversePolish();
$chunk .= $this->writeData($this->_writeDefinedNameBiff8($namedRange->getName(), $formulaData, 0, false));
} catch(Exception $e) {
// do nothing
}
}
}
// total number of sheets
$total_worksheets = count($this->_phpExcel->getAllSheets());
@@ -775,19 +821,28 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// write the print areas, if any
for ($i = 0; $i < $total_worksheets; ++$i) {
if ($this->_phpExcel->getSheet($i)->getPageSetup()->isPrintAreaSet()) {
// Print area
// Print area, e.g. A3:J6,H1:X20
$printArea = PHPExcel_Cell::splitRange($this->_phpExcel->getSheet($i)->getPageSetup()->getPrintArea());
$printArea = $printArea[0];
$printArea[0] = PHPExcel_Cell::coordinateFromString($printArea[0]);
$printArea[1] = PHPExcel_Cell::coordinateFromString($printArea[1]);
$print_rowmin = $printArea[0][1] - 1;
$print_rowmax = $printArea[1][1] - 1;
$print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1;
$print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1;
$countPrintArea = count($printArea);
// construct formula data manually because parser does not recognize absolute 3d cell references
$formulaData = pack('Cvvvvv', 0x3B, $i, $print_rowmin, $print_rowmax, $print_colmin, $print_colmax);
$formulaData = '';
for ($j = 0; $j < $countPrintArea; ++$j) {
$printAreaRect = $printArea[$j]; // e.g. A3:J6
$printAreaRect[0] = PHPExcel_Cell::coordinateFromString($printAreaRect[0]);
$printAreaRect[1] = PHPExcel_Cell::coordinateFromString($printAreaRect[1]);
$print_rowmin = $printAreaRect[0][1] - 1;
$print_rowmax = $printAreaRect[1][1] - 1;
$print_colmin = PHPExcel_Cell::columnIndexFromString($printAreaRect[0][0]) - 1;
$print_colmax = PHPExcel_Cell::columnIndexFromString($printAreaRect[1][0]) - 1;
// construct formula data manually because parser does not recognize absolute 3d cell references
$formulaData .= pack('Cvvvvv', 0x3B, $i, $print_rowmin, $print_rowmax, $print_colmin, $print_colmax);
if ($j > 0) {
$formulaData .= pack('C', 0x10); // list operator token ','
}
}
// store the DEFINEDNAME record
$chunk .= $this->writeData($this->_writeDefinedNameBiff8(pack('C', 0x06), $formulaData, $i + 1, true));
@@ -886,21 +941,34 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Writes Excel BIFF BOUNDSHEET record.
*
* @param string $sheetname Worksheet name
* @param PHPExcel_Worksheet $sheet Worksheet name
* @param integer $offset Location of worksheet BOF
* @access private
*/
function _storeBoundsheet($sheetname,$offset)
function _storeBoundsheet($sheet, $offset)
{
$sheetname = $sheet->getTitle();
$record = 0x0085; // Record identifier
// sheet state
switch ($sheet->getSheetState()) {
case PHPExcel_Worksheet::SHEETSTATE_VISIBLE: $ss = 0x00; break;
case PHPExcel_Worksheet::SHEETSTATE_HIDDEN: $ss = 0x01; break;
case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN: $ss = 0x02; break;
default: $ss = 0x00; break;
}
// sheet type
$st = 0x00;
$grbit = 0x0000; // Visibility and sheet type
if ($this->_BIFF_version == 0x0600) {
$data = pack("Vv", $offset, $grbit);
$data = pack("VCC", $offset, $ss, $st);
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
} else {
$cch = strlen($sheetname); // Length of sheet name
$data = pack("VvC", $offset, $grbit, $cch);
$data = pack("VCCC", $offset, $ss, $st, $cch);
$data .= $sheetname;
}

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Worksheet (used as the base for this class):
@@ -69,6 +69,9 @@ if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
/** PHPExcel_Cell_DataType */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
/** PHPExcel_Writer_Excel5_Parser.php */
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Parser.php';
@@ -81,6 +84,9 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Escher.php';
/** PHPExcel_RichText */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
/** PHPExcel_Shared_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
@@ -105,7 +111,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer/S
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
{
@@ -194,6 +200,11 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
*/
var $_str_table;
/**
* Color cache
*/
private $_colors;
/**
* The temporary dir for storing files
* @var string
@@ -256,8 +267,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
*/
public function __construct($BIFF_version,
&$str_total,
&$str_unique, &$str_table,
$parser, $tempDir = '', $phpSheet)
&$str_unique, &$str_table, &$colors,
$parser, $tempDir = '', $preCalculateFormulas, $phpSheet)
{
// It needs to call its parent's constructor explicitly
parent::__construct();
@@ -269,9 +280,11 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
}
$this->_preCalculateFormulas = $preCalculateFormulas;
$this->_str_total = &$str_total;
$this->_str_unique = &$str_unique;
$this->_str_table = &$str_table;
$this->_colors = &$colors;
$this->_parser = $parser;
$this->_phpSheet = $phpSheet;
@@ -378,12 +391,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Column dimensions
$columnDimensions = $this->_phpSheet->getColumnDimensions();
for ($i = 0; $i < 256; ++$i) {
$width = 9.140625; // assuming Calibri 11
$hidden = 0;
$level = 0;
$xfIndex = 15; // there are 15 cell style Xfs
if ($this->_phpSheet->getDefaultColumnDimension()->getWidth() >= 0) {
$width = $this->_phpSheet->getDefaultColumnDimension()->getWidth();
} else {
$width = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($this->_phpSheet->getParent()->getDefaultStyle()->getFont());
}
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($i);
@@ -394,9 +409,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
}
$hidden = $columnDimension->getVisible() ? 0 : 1;
$level = $columnDimension->getOutlineLevel();
$xfIndex = $columnDimension->getXfIndex() + 15; // there are 15 cell style Xfs
}
$this->_setColumn( $i, $i, $width, null, $hidden, $level);
$this->_setColumn( $i, $i, $width, $xfIndex, $hidden, $level);
}
// Write the COLINFO records if they exist
@@ -472,12 +488,24 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Write sheet protection
$this->_storeProtect();
// Write SCENPROTECT
$this->_writeScenProtect();
// Write OBJECTPROTECT
$this->_writeObjectProtect();
// Write sheet password
$this->_storePassword();
// Write sheet dimensions
$this->_storeDimensions();
// Row dimensions
foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
$xfIndex = $rowDimension->getXfIndex() + 15; // there are 15 cellXfs
$this->_setRow( $rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), $xfIndex, ($rowDimension->getVisible() ? '0' : '1'), $rowDimension->getOutlineLevel() );
}
// Write Cells
foreach ($this->_phpSheet->getCellCollection() as $cell) {
$row = $cell->getRow() - 1;
@@ -505,7 +533,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
break;
case PHPExcel_Cell_DataType::TYPE_FORMULA:
$this->_writeFormula($row, $column, $cell->getValue(), $xfIndex);
$calculatedValue = $this->_preCalculateFormulas ?
$cell->getCalculatedValue() : null;
$this->_writeFormula($row, $column, $cell->getValue(), $xfIndex, $calculatedValue);
break;
case PHPExcel_Cell_DataType::TYPE_BOOL:
@@ -520,19 +550,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_writeNumber($row, $column, $cell->getValue(), $xfIndex);
break;
}
// Hyperlink?
if ($cell->hasHyperlink()) {
$this->_writeUrl($row, $column, str_replace('sheet://', 'internal:', $cell->getHyperlink()->getUrl()));
}
}
}
// Row dimensions
foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
$this->_setRow( $rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), null, ($rowDimension->getVisible() ? '0' : '1'), $rowDimension->getOutlineLevel() );
}
// Append
if ($this->_BIFF_version == 0x0600) {
$this->_storeMsoDrawing();
@@ -542,13 +562,40 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if ($this->_phpSheet->getFreezePane()) {
$this->_storePanes();
}
$this->_storeSelection($this->_selection);
$this->_storeSelection();
$this->_storeMergedCells();
// Hyperlinks
if ($this->_BIFF_version == 0x0600) {
foreach ($this->_phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinate);
$url = $hyperlink->getUrl();
if ( strpos($url, 'sheet://') !== false ) {
// internal to current workbook
$url = str_replace('sheet://', 'internal:', $url);
} else if ( preg_match('/^(http:|https:|ftp:|mailto:)/', $url) ) {
// URL
// $url = $url;
} else {
// external (local file)
$url = 'external:' . $url;
}
$this->_writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url);
}
}
/*if ($this->_BIFF_version == 0x0600) {
$this->_storeDataValidity();
}*/
if ($this->_BIFF_version == 0x0600) {
$this->_storeSheetLayout();
$this->_writeSheetProtection();
$this->_storeRangeProtection();
}
@@ -627,32 +674,18 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $firstcol first column on the range
* @param integer $lastcol last column on the range
* @param integer $width width to set
* @param mixed $format The optional XF format to apply to the columns
* @param integer $xfIndex The optional cell style Xf index to apply to the columns
* @param integer $hidden The optional hidden atribute
* @param integer $level The optional outline level
*/
private function _setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0)
private function _setColumn($firstcol, $lastcol, $width, $xfIndex = 15, $hidden = 0, $level = 0)
{
$this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level);
$this->_colinfo[] = array($firstcol, $lastcol, $width, $xfIndex, $hidden, $level);
// Set width to zero if column is hidden
$width = ($hidden) ? 0 : $width;
}
/**
* Set which cell or cells are selected in a worksheet
*
* @access public
* @param integer $first_row first row in the selected quadrant
* @param integer $first_column first column in the selected quadrant
* @param integer $last_row last row in the selected quadrant
* @param integer $last_column last column in the selected quadrant
*/
function setSelection($first_row,$first_column,$last_row,$last_column)
{
$this->_selection = array($first_row,$first_column,$last_row,$last_column);
}
/**
* Set the option to print the row and column headers on the printed page.
*
@@ -913,18 +946,56 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $col Zero indexed column
* @param string $formula The formula text string
* @param mixed $format The optional XF format
* @param mixed $calculatedValue Calculated value
* @return integer
*/
private function _writeFormula($row, $col, $formula, $xfIndex)
private function _writeFormula($row, $col, $formula, $xfIndex, $calculatedValue)
{
$record = 0x0006; // Record identifier
// Excel normally stores the last calculated value of the formula in $num.
// Clearly we are not in a position to calculate this a priori. Instead
// we set $num to zero and set the option flags in $grbit to ensure
// automatic calculation of the formula when the file is opened.
//
$num = 0x00; // Current value of formula
// Initialize possible additional value for STRING record that should be written after the FORMULA record?
$stringValue = null;
// calculated value
if (isset($calculatedValue)) {
// Since we can't yet get the data type of the calculated value,
// we use best effort to determine data type
if (is_bool($calculatedValue)) {
// Boolean value
$num = pack('CCCvCv', 0x01, 0x00, (int)$calculatedValue, 0x00, 0x00, 0xFFFF);
} elseif (is_int($calculatedValue) || is_float($calculatedValue)) {
// Numeric value
$num = pack('d', $calculatedValue);
} elseif (is_string($calculatedValue)) {
if (array_key_exists($calculatedValue, PHPExcel_Cell_DataType::getErrorCodes())) {
// Error value
$num = pack('CCCvCv', 0x02, 0x00, $this->_mapErrorCode($calculatedValue), 0x00, 0x00, 0xFFFF);
} elseif ($calculatedValue === '' && $this->_BIFF_version == 0x0600) {
// Empty string (and BIFF8)
$num = pack('CCCvCv', 0x03, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
} else {
// Non-empty string value (or empty string BIFF5)
$stringValue = $calculatedValue;
$num = pack('CCCvCv', 0x00, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
}
} else {
// We are really not supposed to reach here
$num = pack('d', 0x00);
}
} else {
$num = pack('d', 0x00);
}
$grbit = 0x03; // Option flags
$unknown = 0x0000; // Must be zero
@@ -948,9 +1019,17 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = 0x16 + $formlen; // Length of the record data
$header = pack("vv", $record, $length);
$data = pack("vvvdvVv", $row, $col, $xfIndex, $num,
$grbit, $unknown, $formlen);
$data = pack("vvv", $row, $col, $xfIndex)
. $num
. pack("vVv", $grbit, $unknown, $formlen);
$this->_append($header . $data . $formula);
// Append also a STRING record if necessary
if ($stringValue !== null) {
$this->_writeStringRecord($stringValue);
}
return 0;
} catch (Exception $e) {
@@ -959,6 +1038,22 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
}
/**
* Write a STRING record. This
*
* @param string $stringValue
*/
private function _writeStringRecord($stringValue)
{
$record = 0x0207; // Record identifier
$data = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($stringValue);
$length = strlen($data);
$header = pack('vv', $record, $length);
$this->_append($header . $data);
}
/**
* Write a hyperlink.
* This is comprised of two elements: the visible label and
@@ -1148,40 +1243,21 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// relative if link starts with up-dir, "..\..\somefile.xls"
// otherwise, absolute
$absolute = 0x02; // Bit mask
if (!preg_match("/\\\/", $url)) {
$absolute = 0x00;
}
if (preg_match("/^\.\.\\\/", $url)) {
$absolute = 0x00;
$absolute = 0x00; // relative path
if ( preg_match('/^[A-Z]:/', $url) ) {
$absolute = 0x02; // absolute path on Windows, e.g. C:\...
}
$link_type = 0x01 | $absolute;
// Determine if the link contains a sheet reference and change some of the
// parameters accordingly.
// Split the dir name and sheet name (if it exists)
/*if (preg_match("/\#/", $url)) {
list($dir_long, $sheet) = split("\#", $url);
} else {
$dir_long = $url;
}
if (isset($sheet)) {
$link_type |= 0x08;
$sheet_len = pack("V", strlen($sheet) + 0x01);
$sheet = join("\0", split('', $sheet));
$sheet .= "\0\0\0";
} else {
$sheet_len = '';
$sheet = '';
}*/
$dir_long = $url;
if (preg_match("/\#/", $url)) {
$link_type |= 0x08;
}
// Pack the link type
$link_type = pack("V", $link_type);
@@ -1193,7 +1269,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0";
// Store the long dir name as a wchar string (non-null terminated)
//$dir_long = join("\0", split('', $dir_long));
$dir_long = $dir_long . "\0";
// Pack the lengths of the dir strings
@@ -1238,11 +1313,11 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $row The row to set
* @param integer $height Height we are giving to the row.
* Use null to set XF without setting height
* @param mixed $format XF format we are giving to the row
* @param integer $xfIndex The optional cell style Xf index to apply to the columns
* @param bool $hidden The optional hidden attribute
* @param integer $level The optional outline level for row, in range [0,7]
*/
private function _setRow($row, $height, $format = null, $hidden = false, $level = 0)
private function _setRow($row, $height, $xfIndex, $hidden = false, $level = 0)
{
$record = 0x0208; // Record identifier
$length = 0x0010; // Number of bytes to follow
@@ -1252,7 +1327,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$irwMac = 0x0000; // Used by Excel to optimise loading
$reserved = 0x0000; // Reserved
$grbit = 0x0000; // Option flags
$ixfe = 0x0F; // hard-coding XF index
$ixfe = $xfIndex;
if ( $height < 0 ){
$height = null;
@@ -1275,8 +1350,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if ($hidden) {
$grbit |= 0x0020;
}
$grbit |= 0x0040; // fUnsynced
if ($format) {
if ($height !== null) {
$grbit |= 0x0040; // fUnsynced
}
if ($xfIndex !== 0xF) {
$grbit |= 0x0080;
}
$grbit |= 0x0100;
@@ -1451,9 +1528,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$coldx = 8.43;
}
if (isset($col_array[3])) {
$format = $col_array[3];
$xfIndex = $col_array[3];
} else {
$format = 0;
$xfIndex = 15;
}
if (isset($col_array[4])) {
$grbit = $col_array[4];
@@ -1470,7 +1547,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$coldx *= 256; // Convert to units of 1/256 of a char
$ixfe = 0x0F; // hard-coding XF index
$ixfe = $xfIndex;
$reserved = 0x00; // Reserved
$level = max(0, min($level, 7));
@@ -1486,12 +1563,39 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* Write BIFF record SELECTION.
*
* @access private
* @param array $array array containing ($rwFirst,$colFirst,$rwLast,$colLast)
* @see setSelection()
*/
function _storeSelection($array)
function _storeSelection()
{
list($rwFirst,$colFirst,$rwLast,$colLast) = $array;
// look up the selected cell range
$selectedCells = $this->_phpSheet->getSelectedCells();
$selectedCells = PHPExcel_Cell::splitRange($this->_phpSheet->getSelectedCells());
$selectedCells = $selectedCells[0];
if (count($selectedCells) == 2) {
list($first, $last) = $selectedCells;
} else {
$first = $selectedCells[0];
$last = $selectedCells[0];
}
list($colFirst, $rwFirst) = PHPExcel_Cell::coordinateFromString($first);
$colFirst = PHPExcel_Cell::columnIndexFromString($colFirst) - 1; // base 0 column index
--$rwFirst; // base 0 row index
list($colLast, $rwLast) = PHPExcel_Cell::coordinateFromString($last);
$colLast = PHPExcel_Cell::columnIndexFromString($colLast) - 1; // base 0 column index
--$rwLast; // base 0 row index
// make sure we are not out of bounds
$colFirst = min($colFirst, 255);
$colLast = min($colLast, 255);
if ($this->_BIFF_version == 0x0600) {
$rwFirst = min($rwFirst, 65535);
$rwLast = min($rwLast, 65535);
} else {
$rwFirst = min($rwFirst, 16383);
$rwLast = min($rwLast, 16383);
}
$record = 0x001D; // Record identifier
$length = 0x000F; // Number of bytes to follow
@@ -1585,6 +1689,77 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
}
}
/**
* Write SHEETLAYOUT record
*/
private function _storeSheetLayout()
{
if (!$this->_phpSheet->isTabColorSet()) {
return;
}
$recordData = pack(
'vvVVVvv'
, 0x0862
, 0x0000 // unused
, 0x00000000 // unused
, 0x00000000 // unused
, 0x00000014 // size of record data
, $this->_colors[$this->_phpSheet->getTabColor()->getRGB()] // color index
, 0x0000 // unused
);
$length = strlen($recordData);
$record = 0x0862; // Record identifier
$header = pack('vv', $record, $length);
$this->_append($header . $recordData);
}
/**
* Write SHEETPROTECTION
*/
private function _writeSheetProtection()
{
// record identifier
$record = 0x0867;
// prepare options
$options = (int) !$this->_phpSheet->getProtection()->getObjects()
| (int) !$this->_phpSheet->getProtection()->getScenarios() << 1
| (int) !$this->_phpSheet->getProtection()->getFormatCells() << 2
| (int) !$this->_phpSheet->getProtection()->getFormatColumns() << 3
| (int) !$this->_phpSheet->getProtection()->getFormatRows() << 4
| (int) !$this->_phpSheet->getProtection()->getInsertColumns() << 5
| (int) !$this->_phpSheet->getProtection()->getInsertRows() << 6
| (int) !$this->_phpSheet->getProtection()->getInsertHyperlinks() << 7
| (int) !$this->_phpSheet->getProtection()->getDeleteColumns() << 8
| (int) !$this->_phpSheet->getProtection()->getDeleteRows() << 9
| (int) !$this->_phpSheet->getProtection()->getSelectLockedCells() << 10
| (int) !$this->_phpSheet->getProtection()->getSort() << 11
| (int) !$this->_phpSheet->getProtection()->getAutoFilter() << 12
| (int) !$this->_phpSheet->getProtection()->getPivotTables() << 13
| (int) !$this->_phpSheet->getProtection()->getSelectUnlockedCells() << 14 ;
// record data
$recordData = pack(
'vVVCVVvv'
, 0x0867 // repeated record identifier
, 0x0000 // not used
, 0x0000 // not used
, 0x00 // not used
, 0x01000200 // unknown data
, 0xFFFFFFFF // unknown data
, $options // options
, 0x0000 // not used
);
$length = strlen($recordData);
$header = pack('vv', $record, $length);
$this->_append($header . $recordData);
}
/**
* Write BIFF record RANGEPROTECTION
*
@@ -2156,7 +2331,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if ($this->_phpSheet->getShowSummaryRight()) {
$grbit |= 0x0080; // Outline summary right
}
if ($this->_phpSheet->getPageSetup()->getFitToWidth() || $this->_phpSheet->getPageSetup()->getFitToHeight()) {
if ($this->_phpSheet->getPageSetup()->getFitToPage()) {
$grbit |= 0x0100; // Page setup fit to page
}
if ($this->_outline_on) {
@@ -2292,6 +2467,54 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_append($header.$data);
}
/**
* Write SCENPROTECT
*/
private function _writeScenProtect()
{
// Exit if sheet protection is not active
if (!$this->_phpSheet->getProtection()->getSheet()) {
return;
}
// Exit if scenarios are not protected
if (!$this->_phpSheet->getProtection()->getScenarios()) {
return;
}
$record = 0x00DD; // Record identifier
$length = 0x0002; // Bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', 1);
$this->_append($header . $data);
}
/**
* Write OBJECTPROTECT
*/
private function _writeObjectProtect()
{
// Exit if sheet protection is not active
if (!$this->_phpSheet->getProtection()->getSheet()) {
return;
}
// Exit if objects are not protected
if (!$this->_phpSheet->getProtection()->getObjects()) {
return;
}
$record = 0x0063; // Record identifier
$length = 0x0002; // Bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', 1);
$this->_append($header . $data);
}
/**
* Write the worksheet PASSWORD record.
*

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Format (used as the base for this class):
@@ -87,7 +87,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Protection.php';
*
* @category PHPExcel
* @package PHPExcel_Writer_Excel5
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Excel5_Xf
{
@@ -234,7 +234,7 @@ class PHPExcel_Writer_Excel5_Xf
if ($this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
$this->_left_color = 0;
}
if ($this->_diag == 0) {
if ($this->_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
$this->_diag_color = 0;
}
@@ -302,15 +302,19 @@ class PHPExcel_Writer_Excel5_Xf
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
$border1 |= $this->_left_color << 16;
$border1 |= $this->_right_color << 23;
$diag_tl_to_rb = 0;
$diag_tr_to_lb = 0;
$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
$border1 |= $diag_tl_to_rb << 30;
$border1 |= $diag_tr_to_lb << 31;
$border2 = $this->_top_color; // Border color
$border2 |= $this->_bottom_color << 7;
$border2 |= $this->_diag_color << 14;
$border2 |= $this->_diag << 21;
$border2 |= $this->_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
$border2 |= $this->_mapFillType($this->_style->getFill()->getFillType()) << 26;
$header = pack("vv", $record, $length);
@@ -395,6 +399,17 @@ class PHPExcel_Writer_Excel5_Xf
$this->_right_color = $colorIndex;
}
/**
* Sets the cell's diagonal border color
*
* @access public
* @param int $colorIndex Color index
*/
function setDiagColor($colorIndex)
{
$this->_diag_color = $colorIndex;
}
/**
* Sets the cell's foreground color

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -58,7 +58,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/HashTable.php';
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
/**
@@ -111,11 +111,39 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
private $_columnWidths = null;
/**
* Default font size
* Default font
*
* @var int
* @var PHPExcel_Style_Font
*/
private $_defaultFontSize;
private $_defaultFont;
/**
* Flag whether spans have been calculated
*
* @var boolean
*/
private $_spansAreCalculated;
/**
* Excel cells that should not be written as HTML cells
*
* @var array
*/
private $_isSpannedCell;
/**
* Excel cells that are upper-left corner in a cell merge
*
* @var array
*/
private $_isBaseCell;
/**
* Excel rows that should not be written as HTML rows
*
* @var array
*/
private $_isSpannedRow;
/**
* Is the current writer creating PDF?
@@ -131,9 +159,14 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
*/
public function __construct(PHPExcel $phpExcel) {
$this->_phpExcel = $phpExcel;
$this->_defaultFontSize = $this->_phpExcel->getDefaultStyle()->getFont()->getSize();
$this->_defaultFont = $this->_phpExcel->getDefaultStyle()->getFont();
$this->_sheetIndex = 0;
$this->_imagesRoot = '.';
$this->_spansAreCalculated = false;
$this->_isSpannedCell = array();
$this->_isBaseCell = array();
$this->_isSpannedRow = array();
}
/**
@@ -210,6 +243,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
case PHPExcel_Style_Border::BORDER_NONE: return '0px';
case PHPExcel_Style_Border::BORDER_DASHED: return '1px dashed';
case PHPExcel_Style_Border::BORDER_DOTTED: return '1px dotted';
case PHPExcel_Style_Border::BORDER_DOUBLE: return '3px double';
case PHPExcel_Style_Border::BORDER_THICK: return '2px solid';
default: return '1px solid'; // map others to thin
}
@@ -286,6 +320,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
throw new Exception('Internal PHPExcel object not set to an instance of an object.');
}
// Ensure that Spans have been calculated?
if (!$this->_spansAreCalculated) {
$this->_calculateSpans();
}
// Fetch sheets
$sheets = array();
if (is_null($this->_sheetIndex)) {
@@ -300,9 +339,6 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// Loop all sheets
$sheetId = 0;
foreach ($sheets as $sheet) {
// Get cell collection
$cellCollection = $sheet->getCellCollection();
// Write table header
$html .= $this->_generateTableHeader($sheet);
@@ -313,13 +349,13 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]);
$dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1;
// Loop trough cells
// Loop through cells
$rowData = null;
for ($row = $dimension[0][1]; $row <= $dimension[1][1]; ++$row) {
// Start a new row
$rowData = array();
// Loop trough columns
// Loop through columns
for ($column = $dimension[0][0]; $column <= $dimension[1][0]; ++$column) {
// Cell exists?
if ($sheet->cellExistsByColumnAndRow($column, $row)) {
@@ -329,8 +365,10 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
}
}
// Write row
$html .= $this->_generateRow($sheet, $rowData, $row - 1);
// Write row if there are HTML table cells in it
if ( !isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row]) ) {
$html .= $this->_generateRow($sheet, $rowData, $row - 1);
}
}
// Write table footer
@@ -455,6 +493,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
return $this->_cssStyles;
}
// Ensure that spans have been calculated
if (!$this->_spansAreCalculated) {
$this->_calculateSpans();
}
// Construct CSS
$css = array();
@@ -523,7 +566,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// col elements, loop through columnDimensions and set width
foreach ($sheet->getColumnDimensions() as $columnDimension) {
if (($width = PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->_defaultFontSize)) >= 0) {
if (($width = PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->_defaultFont)) >= 0) {
$width = PHPExcel_Shared_Drawing::pixelsToPoints($width);
$column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
$this->_columnWidths[$sheetIndex][$column] = $width;
@@ -542,7 +585,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// table.sheetN tr { }
$css['table.sheet' . $sheetIndex . ' tr'] = array();
$pt_height = $rowDimension->getRowHeight();
if ($rowDimension->getRowHeight() == -1) {
$pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
} else {
$pt_height = $rowDimension->getRowHeight();
}
$css['table.sheet' . $sheetIndex . ' tr']['height'] = $pt_height . 'pt';
if ($rowDimension->getVisible() === false) {
$css['table.sheet' . $sheetIndex . ' tr']['display'] = 'none';
@@ -556,7 +603,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// table.sheetN tr.rowYYYYYY { }
$css['table.sheet' . $sheetIndex . ' tr.row' . $row] = array();
$pt_height = $rowDimension->getRowHeight();
if ($rowDimension->getRowHeight() == -1) {
$pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont());
} else {
$pt_height = $rowDimension->getRowHeight();
}
$css['table.sheet' . $sheetIndex . ' tr.row' . $row]['height'] = $pt_height . 'pt';
if ($rowDimension->getVisible() === false) {
$css['table.sheet' . $sheetIndex . ' tr.row' . $row]['display'] = 'none';
@@ -822,7 +873,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// Value
if ($cell->getValue() instanceof PHPExcel_RichText) {
// Loop trough rich text elements
// Loop through rich text elements
$elements = $cell->getValue()->getRichTextElements();
foreach ($elements as $element) {
// Rich text start?
@@ -854,17 +905,16 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
if ($this->_preCalculateFormulas) {
$cellData = PHPExcel_Style_NumberFormat::toFormattedString(
$cell->getCalculatedValue(),
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode()
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(),
array($this, 'formatColor')
);
} else {
$cellData = PHPExcel_Style_NumberFormat::ToFormattedString(
$cell->getValue(),
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode()
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(),
array($this, 'formatColor')
);
}
// Convert UTF8 data to PCDATA
$cellData = htmlspecialchars($cellData);
}
// replace leading spaces on each line with &nbsp;
@@ -910,19 +960,17 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$cellData = '<a href="' . htmlspecialchars($cell->getHyperlink()->getUrl()) . '" title="' . htmlspecialchars($cell->getHyperlink()->getTooltip()) . '">' . $cellData . '</a>';
}
// Column/rowspan
foreach ($pSheet->getMergeCells() as $cells) {
if ($cell->isInRange($cells)) {
list($first, ) = PHPExcel_Cell::splitRange($cells);
// Should the cell be written or is it swallowed by a rowspan or colspan?
$writeCell = ! ( isset($this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])
&& $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum] );
if ($first[0] == $cell->getCoordinate()) {
list($colSpan, $rowSpan) = PHPExcel_Cell::rangeDimension($cells);
} else {
$writeCell = false;
}
break;
}
// Colspan and Rowspan
$colspan = 1;
$rowspan = 1;
if (isset($this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])) {
$spans = $this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum];
$rowSpan = $spans['rowspan'];
$colSpan = $spans['colspan'];
}
// Write
@@ -1085,4 +1133,122 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
return $string;
}
/**
* Add color to formatted string as inline style
*
* @param string $pValue Plain formatted value without color
* @param string $pFormat Format code
* @return string
*/
public function formatColor($pValue, $pFormat)
{
// Color information, e.g. [Red] is always at the beginning
$color = null; // initialize
$matches = array();
$color_regex = '/^\\[[a-zA-Z]+\\]/';
if (preg_match($color_regex, $pFormat, $matches)) {
$color = str_replace('[', '', $matches[0]);
$color = str_replace(']', '', $color);
$color = strtolower($color);
}
// convert to PCDATA
$value = htmlspecialchars($pValue);
// color span tag
if ($color !== null) {
$value = '<span style="color:' . $color . '">' . $value . '</span>';
}
return $value;
}
/**
* Calculate information about HTML colspan and rowspan which is not always the same as Excel's
*/
private function _calculateSpans()
{
// Identify all cells that should be omitted in HTML due to cell merge.
// In HTML only the upper-left cell should be written and it should have
// appropriate rowspan / colspan attribute
$sheetIndexes = $this->_sheetIndex !== null ?
array($this->_sheetIndex) : range(0, $this->_phpExcel->getSheetCount() - 1);
foreach ($sheetIndexes as $sheetIndex) {
$sheet = $this->_phpExcel->getSheet($sheetIndex);
$candidateSpannedRow = array();
// loop through all Excel merged cells
foreach ($sheet->getMergeCells() as $cells) {
list($cells, ) = PHPExcel_Cell::splitRange($cells);
$first = $cells[0];
$last = $cells[1];
list($fc, $fr) = PHPExcel_Cell::coordinateFromString($first);
$fc = PHPExcel_Cell::columnIndexFromString($fc) - 1;
list($lc, $lr) = PHPExcel_Cell::coordinateFromString($last);
$lc = PHPExcel_Cell::columnIndexFromString($lc) - 1;
// loop through the individual cells in the individual merge
for ($r = $fr; $r <= $lr; ++$r) {
// also, flag this row as a HTML row that is candidate to be omitted
$candidateSpannedRow[$r] = $r;
for ($c = $fc; $c <= $lc; ++$c) {
if ( !($c == $fc && $r == $fr) ) {
// not the upper-left cell (should not be written in HTML)
$this->_isSpannedCell[$sheetIndex][$r][$c] = array(
'baseCell' => array($fr, $fc),
);
} else {
// upper-left is the base cell that should hold the colspan/rowspan attribute
$this->_isBaseCell[$sheetIndex][$r][$c] = array(
'xlrowspan' => $lr - $fr + 1, // Excel rowspan
'rowspan' => $lr - $fr + 1, // HTML rowspan, value may change
'xlcolspan' => $lc - $fc + 1, // Excel colspan
'colspan' => $lc - $fc + 1, // HTML colspan, value may change
);
}
}
}
}
// Identify which rows should be omitted in HTML. These are the rows where all the cells
// participate in a merge and the where base cells are somewhere above.
$countColumns = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn());
foreach ($candidateSpannedRow as $rowIndex) {
if (isset($this->_isSpannedCell[$sheetIndex][$rowIndex])) {
if (count($this->_isSpannedCell[$sheetIndex][$rowIndex]) == $countColumns) {
$this->_isSpannedRow[$sheetIndex][$rowIndex] = $rowIndex;
};
}
}
// For each of the omitted rows we found above, the affected rowspans should be subtracted by 1
if ( isset($this->_isSpannedRow[$sheetIndex]) ) {
foreach ($this->_isSpannedRow[$sheetIndex] as $rowIndex) {
$adjustedBaseCells = array();
for ($c = 0; $c < $countColumns; ++$c) {
$baseCell = $this->_isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
if ( !in_array($baseCell, $adjustedBaseCells) ) {
// subtract rowspan by 1
--$this->_isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan'];
$adjustedBaseCells[] = $baseCell;
}
}
}
}
// TODO: Same for columns
}
// We have calculated the spans
$this->_spansAreCalculated = true;
}
}

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Writer_IWriter
{

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -49,6 +49,9 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
/** PHPExcel_Shared_Drawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
/** PHPExcel_Shared_File */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
/** PHPExcel_HashTable */
require_once PHPEXCEL_ROOT . 'PHPExcel/HashTable.php';
@@ -61,7 +64,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PDF.php';
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_PDF extends PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
/**
@@ -79,7 +82,7 @@ class PHPExcel_Writer_PDF extends PHPExcel_Writer_HTML implements PHPExcel_Write
public function __construct(PHPExcel $phpExcel) {
parent::__construct($phpExcel);
$this->setUseInlineCss(true);
$this->_tempDir = sys_get_temp_dir();
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
}
/**
@@ -129,7 +132,13 @@ class PHPExcel_Writer_PDF extends PHPExcel_Writer_HTML implements PHPExcel_Write
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
// Set the appropriate font
$pdf->SetFont('freesans');
//$pdf->SetFont('arialunicid0-chinese-simplified');
//$pdf->SetFont('arialunicid0-chinese-traditional');
//$pdf->SetFont('arialunicid0-korean');
//$pdf->SetFont('arialunicid0-japanese');
$pdf->writeHTML($html);
// Document info

View File

@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2009 PHPExcel
* Copyright (c) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,9 +20,9 @@
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.0, 2009-08-10
* @version 1.7.2, 2010-01-11
*/
@@ -58,7 +58,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
*
* @category PHPExcel
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_Serialized implements PHPExcel_Writer_IWriter
{
@@ -190,10 +190,10 @@ class PHPExcel_Writer_Serialized implements PHPExcel_Writer_IWriter
// PHPExcel
$objWriter->startElement('PHPExcel');
$objWriter->writeAttribute('version', '1.7.0');
$objWriter->writeAttribute('version', '1.7.2');
// Comment
$objWriter->writeComment('This file has been generated using PHPExcel v1.7.0 (http://www.codeplex.com/PHPExcel). It contains a base64 encoded serialized version of the PHPExcel internal object.');
$objWriter->writeComment('This file has been generated using PHPExcel v1.7.2 (http://www.codeplex.com/PHPExcel). It contains a base64 encoded serialized version of the PHPExcel internal object.');
// Data
$objWriter->startElement('data');