Source for file Workbook.php
Documentation is available at Workbook.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* Created on 22. Jul. 2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* Speadsheet_OpenDocument_Workbook class file.
* Implementation of a Workbook for OpenDocuments like the PEAR_Spreadsheet_Writer
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the GPL. For more information please see
* <http://opendocumentphp.org>.
* $Id: Workbook.php 257 2007-08-02 12:19:56Z nmarkgraf $
* @package OpenDocumentPHP
* @subpackage util_Spreadsheet
* @author Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* @copyright Copyright in 2006, 2007 by The OpenDocumentPHP Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
* @version SVN: $Id: Workbook.php 257 2007-08-02 12:19:56Z nmarkgraf $
* @link http://opendocumentphp.org
* @link http://pear.php.net/package/Spreadsheet_Excel_Writer
* @since 0.6.0 - 22. Jul. 2007
require_once 'OpenDocumentPHP/OpenDocumentArchive.php';
require_once 'OpenDocumentPHP/util/Spreadsheet/Worksheet.php';
* Spreadsheet_OpenDocument_Workbook
* @package OpenDocumentPHP
* @subpackage util_Spreadsheet
* @author Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
* @copyright Copyright in 2006, 2007 by The OpenDocumentPHP Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
* @version Release: @package_version@
* @link http://opendocumentphp.org
* @link http://pear.php.net/package/Spreadsheet_Excel_Writer
* @since 0.6.0 - 22. Jul. 2007
* Connect this Workbook to the $opendocument
* Initialize the worksheets array
* Initialize automatic-styles class.
* <style:style style:name="DefaultColumn" style:family="table-column">
* <style:table-column-properties fo:break-before="auto"
* style:column-width="2.267cm" />
$defColStyle->appendChild($tableColumnProperties);
$tableColumnProperties->setColumnWidth('2.267cm');
* <style:style style:name="ro1" style:family="table-row">
* <style:table-row-properties style:row-height="0.453cm"
* style:use-optimal-row-height="true" />
$defRowStyle->appendChild($tableRowProperties);
$tableRowProperties->setRowHeight('0.453cm');
$tableRowProperties->setUseOptimalRowHeight();
<style:style style:name="co2" style:family="table-column">
<style:table-column-properties fo:break-before="auto"
style:column-width="1cm" />
* @return Worksheet|PEAR_ErrorWorksheet object on success, PEAR_Error on failure
* Check if $opendocument is from type Calc.
* Connect this Worksheet to the $opendocument
$this->mainOpenDocument = $opendocument;
* Check if no $name was given, in this case we need to find a free space
* and add the new worksheer there.
* Create a new OpenDocument Worksheet
* Add it to the worksheet list
* return the new worksheet
* @param $properties array
* @return bool|PEAR_Errortrue on success, PEAR_Error on failure
* We need to check if there is any worksheet in the workbook.
* If there are some, we include ever worksheet to the
* OpenDocument calc archive
* Get body object of the OpenDocument.
$table = $body->getNewTableFragment($worksheet->getName());
* If this worksheet is protected by a password...
if ($worksheet->proteced) {
* ... add password to the table in the OpenDocument
$table->setProtection('true', $worksheet->protectionKey);
* Put cells into the OpenDocument
$cells = $worksheet->getCells();
foreach($cells as $row => $cellRow) {
foreach($cellRow as $col => $cellRowCol) {
switch ($cellRowCol['type']) {
$cell = $table->getCell($col, $row);
$cell->setLinkContent($cellRowCol['url'], $cellRowCol['token']);
$table->setCellContent($cellRowCol['token'], $col, $row);
$tmp = $body->getDocumentFragment();
$this->_automaticStyles->appendChild($newStyle);
$newStyle->setStyleName('au'. "$counter");
$newStyle->setStyleName($name);
|