2016-10-06 15:57:01 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Project:
|
|
|
|
* Contenido Content Management System
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Excel handling class
|
|
|
|
*
|
|
|
|
* Requirements:
|
|
|
|
* @con_php_req 5.0
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @package Contenido Backend classes
|
|
|
|
* @version 1.0.2
|
|
|
|
* @author Timo A. Hummel
|
|
|
|
* @copyright four for business AG <www.4fb.de>
|
|
|
|
* @license http://www.contenido.org/license/LIZENZ.txt
|
|
|
|
* @link http://www.4fb.de
|
|
|
|
* @link http://www.contenido.org
|
|
|
|
* @since file available since contenido release <= 4.6
|
|
|
|
*
|
|
|
|
* {@internal
|
|
|
|
* created unknown
|
|
|
|
* modified 2008-06-30, Dominik Ziegler, add security fix
|
|
|
|
*
|
2019-07-03 11:58:28 +00:00
|
|
|
* $Id$:
|
2016-10-06 15:57:01 +00:00
|
|
|
* }}
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(!defined('CON_FRAMEWORK')) {
|
|
|
|
die('Illegal call');
|
|
|
|
}
|
|
|
|
|
|
|
|
cInclude('pear', 'Spreadsheet/Excel/Writer.php');
|
|
|
|
|
|
|
|
class ExcelWorksheet
|
|
|
|
{
|
|
|
|
var $_data = array();
|
|
|
|
var $_title;
|
|
|
|
var $_filename;
|
|
|
|
|
2018-12-10 12:13:27 +00:00
|
|
|
function __construct ($title, $filename)
|
2016-10-06 15:57:01 +00:00
|
|
|
{
|
|
|
|
$this->_title = Contenido_Security::escapeDB($title, null);
|
|
|
|
$this->_filename = Contenido_Security::escapeDB($filename, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setRow ($row)
|
|
|
|
{
|
|
|
|
$row = Contenido_Security::escapeDB($row, null);
|
|
|
|
$args = func_num_args();
|
|
|
|
|
|
|
|
for ($arg=1;$arg<$args;$arg++)
|
|
|
|
{
|
|
|
|
$ma = func_get_arg($arg);
|
|
|
|
$this->setCell($row, $arg, $ma);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setCell($row, $cell, $data)
|
|
|
|
{
|
|
|
|
$row = Contenido_Security::escapeDB($row, null);
|
|
|
|
$cell = Contenido_Security::escapeDB($cell, null);
|
|
|
|
$data = Contenido_Security::escapeDB($data, null);
|
|
|
|
$this->_data[$row][$cell] = $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function make ()
|
|
|
|
{
|
|
|
|
|
|
|
|
$workbook = new Spreadsheet_Excel_Writer();
|
|
|
|
$workbook->send($this->_filename);
|
|
|
|
|
|
|
|
$worksheet = & $workbook->addWorksheet($this->_title);
|
|
|
|
|
|
|
|
foreach ($this->_data as $row => $line)
|
|
|
|
{
|
|
|
|
foreach ($line as $col => $coldata)
|
|
|
|
{
|
|
|
|
$worksheet->writeString($row-1, $col-1, $coldata);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$workbook->close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|