2
0
forked from Wavyzz/dolibarr

Qual: Removed php_writexcel lib. Replaced with phpexcell.

Fix: Make script export-contaxts-xls-example.php working.
Qual: removed not used code.
This commit is contained in:
Laurent Destailleur
2011-08-11 19:12:37 +00:00
parent b5d1b3ee46
commit 76f1880583
43 changed files with 224 additions and 10717 deletions

View File

@@ -611,7 +611,7 @@ RECURSIVE = YES
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE = ../../mssql ../../mysql ../../pgsql ../../CVS ../../build ../../dev ../../doc ../../documents ../../htdocs/conf/conf.php ../../htdocs/includes/adodbtime ../../htdocs/includes/artichow ../../htdocs/includes/barcode ../../htdocs/includes/ckeditor ../../htdocs/includes/efc_xfss ../../htdocs/includes/fckeditor ../../htdocs/includes/flot ../../htdocs/includes/fpdf ../../htdocs/includes/geoip ../../htdocs/includes/jquery ../../htdocs/includes/magpierss ../../htdocs/includes/nusoap ../../htdocs/includes/odtphp ../../htdocs/includes/pear ../../htdocs/includes/phpexcel ../../htdocs/includes/php_writeexcel ../../htdocs/includes/phplot ../../htdocs/includes/phplot5 ../../htdocs/includes/pwc ../../htdocs/includes/scriptaculous ../../htdocs/includes/smtps ../../htdocs/includes/tcpdf ../../htdocs/includes/vcard ../../htdocs/cashdesk/include/jscalendar ../../htdocs/avoir ../../htdocs/document ../../htdocs/documents ../../htdocs/lolix ../../htdocs/postnuke ../../htdocs/rapport ../../htdocs/telephonie ../../htdocs/voyage ../../htdocs/oscommerce_ws/ws_client_demo ../../htdocs/oscommerce_ws/ws_server ../../scripts/addons ../../scripts/courrier ../../scripts/lolix ../../scripts/energie
EXCLUDE = ../../mssql ../../mysql ../../pgsql ../../CVS ../../build ../../dev ../../doc ../../documents ../../htdocs/conf/conf.php ../../htdocs/includes/adodbtime ../../htdocs/includes/artichow ../../htdocs/includes/barcode ../../htdocs/includes/ckeditor ../../htdocs/includes/efc_xfss ../../htdocs/includes/fckeditor ../../htdocs/includes/fpdi ../../htdocs/includes/geoip ../../htdocs/includes/jquery ../../htdocs/includes/magpierss ../../htdocs/includes/nusoap ../../htdocs/includes/odtphp ../../htdocs/includes/pear ../../htdocs/includes/phpexcel ../../htdocs/includes/smtps ../../htdocs/includes/tcpdf ../../htdocs/includes/vcard ../../htdocs/cashdesk/include/jscalendar ../../htdocs/avoir ../../htdocs/document ../../htdocs/documents ../../htdocs/lolix ../../htdocs/postnuke ../../htdocs/rapport ../../htdocs/telephonie ../../htdocs/voyage ../../htdocs/oscommerce_ws/ws_client_demo ../../htdocs/oscommerce_ws/ws_server ../../scripts/addons ../../scripts/courrier ../../scripts/lolix ../../scripts/energie
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded

View File

@@ -2,7 +2,7 @@
#----------------------------------------------------------------------------
# \file build/makepack-dolibarr.pl
# \brief Dolibarr package builder (tgz, zip, rpm, deb, exe, aps)
# \version $Id: makepack-dolibarr.pl,v 1.140 2011/08/10 23:30:20 eldy Exp $
# \version $Id: makepack-dolibarr.pl,v 1.141 2011/08/11 19:13:02 eldy Exp $
# \author (c)2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
#----------------------------------------------------------------------------
@@ -45,7 +45,7 @@ if (-d "/usr/src/RPM") { $RPMDIR="/usr/src/RPM"; } # mandrake
use vars qw/ $REVISION $VERSION /;
$REVISION='$Revision: 1.140 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
$REVISION='$Revision: 1.141 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
$VERSION="3.1 (build $REVISION)";
@@ -313,8 +313,6 @@ if ($nboftargetok) {
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/jcrop/js/jquery.min.js`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/odtphp/zip/.svn`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/odtphp/zip/pclzip/.svn`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/php_writeexcel/php.bmp`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.33`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-20100919`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`;
@@ -496,12 +494,10 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/cashdesk/include/jscalendar/skins/aqua/CVS`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/ckeditor/plugins/*/dialogs/CVS`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/ckeditor/plugins/*/images/CVS`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/fpdf/fpdf`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/odtphp/zip/.svn`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip/.svn`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip/gnu-lgpl.txt`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/php_writeexcel/LICENSE`;
$ret=`rm -f $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/COPYING`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/barcode/php-barcode/genbarcode`;
@@ -716,13 +712,11 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/cashdesk/include/jscalendar/skins/aqua/CVS`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/ckeditor/plugins/*/dialogs/CVS`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/ckeditor/plugins/*/images/CVS`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/fpdf/fpdf`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/.svn`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip/.svn`;
$ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/fckeditor/license.txt`;
$ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/jquery/plugins/flot/LICENSE.txt`;
$ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/php_writeexcel/LICENSE`;
$ret=`rm -f $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/tcpdf/LICENSE.TXT`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/barcode/php-barcode/genbarcode`;
# To remove once stable
@@ -876,7 +870,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/build/zip`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/build/perl`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/dbmodel`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/fpdf`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/initdata`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/iso-normes`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/$PROJECT/dev/phpcheckstyle`;

View File

@@ -20,7 +20,7 @@
* \file htdocs/exports/export.php
* \ingroup export
* \brief Pages of export Wizard
* \version $Id: export.php,v 1.83 2011/07/31 23:50:55 eldy Exp $
* \version $Id: export.php,v 1.84 2011/08/11 19:12:59 eldy Exp $
*/
require_once("../main.inc.php");
@@ -779,7 +779,7 @@ if ($step == 4 && $datatoexport)
print '<table width="100%"><tr><td width="50%">';
if (! is_dir($conf->export->dir_temp)) create_exdir($conf->export->dir_temp);
if (! is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp);
// Affiche liste des documents
// NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste
@@ -787,18 +787,6 @@ if ($step == 4 && $datatoexport)
print '</td><td width="50%">&nbsp;</td></tr>';
print '</table>';
// If external library PHPEXCELREADER is available
// and defined by PHPEXCELREADER constant.
if (file_exists(PHPEXCELREADER.'excelreader.php'))
{
// Test d'affichage du tableau excel et csv
//print '<table width="100%"><tr><td>';
//require_once(DOL_DOCUMENT_ROOT.'/lib/viewfiles.lib.php');
//viewExcelFileContent($conf->export->dir_temp.'/1/export_member_1.xls',5,3);
//viewCsvFileContent($conf->export->dir_temp.'/1/export_member_1.csv',5);
//print '</td></tr></table>';
}
}
@@ -807,7 +795,7 @@ print '<br>';
$db->close();
llxFooter('$Date: 2011/07/31 23:50:55 $ - $Revision: 1.83 $');
llxFooter('$Date: 2011/08/11 19:12:59 $ - $Revision: 1.84 $');
/**

View File

@@ -3,6 +3,7 @@ This file describe changes made on external library after beeing included
in Dolibarr root.
ALL:
----
Replace "& new" by "new"
@@ -21,10 +22,6 @@ By
Replace call to serialize_val with no bugged value
FPDFI and FPDF_TPL:
-------------------
* Replaced all sprintf(%0.2f) by sprintf(%0.2F) (Fix bug)
TCPDF:
------
@@ -42,6 +39,7 @@ if (! function_exists('getmypid')) {
}
JSGANTT:
--------
* Replace in function JSGantt.taskLink

View File

@@ -20,13 +20,10 @@
* \ingroup export
* \brief File of class to generate export file with Excel format
* \author Laurent Destailleur
* \version $Id: export_excel.modules.php,v 1.28 2011/08/03 01:38:53 eldy Exp $
* \version $Id: export_excel.modules.php,v 1.29 2011/08/11 19:13:04 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/export/modules_export.php");
require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbookbig.inc.php");
require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
require_once(PHP_WRITEEXCEL_PATH."/functions.writeexcel_utility.inc.php");
/**
@@ -47,11 +44,13 @@ class ExportExcel extends ModeleExports
var $worksheet; // Handle onglet
var $row;
var $col;
var $file; // To save filename
/**
* \brief Constructor
* \param db databse handler
* Constructor
*
* @param db databse handler
*/
function ExportExcel($db)
{
@@ -63,12 +62,12 @@ class ExportExcel extends ModeleExports
$this->desc='<b>Excel</b> file format (.xls)<br>This is native Excel 95 format.';
$this->extension='xls'; // Extension for generated file by this driver
$this->picto='mime/xls'; // Picto
$ver=explode(' ','$Revision: 1.28 $');
$ver=explode(' ','$Revision: 1.29 $');
$this->version=$ver[2]; // Driver version
// If driver use an external library, put its name here
$this->label_lib='Php_WriteExcel';
$this->version_lib='0.3.0';
$this->label_lib='PhpExcel';
$this->version_lib='1.7.2';
$this->row=0;
}
@@ -110,37 +109,62 @@ class ExportExcel extends ModeleExports
/**
* \brief Open output file
* \param file Path of filename
* \return int <0 if KO, >=0 if OK
* Open output file
*
* @param file Path of filename
* @return int <0 if KO, >=0 if OK
*/
function open_file($file,$outputlangs)
{
global $conf,$langs;
global $user,$conf,$langs;
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
}
dol_syslog("ExportExcel::open_file file=".$file);
$this->file=$file;
$ret=1;
$outputlangs->load("exports");
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
require_once(PHP_WRITEEXCEL_PATH."class.writeexcel_workbookbig.inc.php");
require_once(PHP_WRITEEXCEL_PATH."class.writeexcel_worksheet.inc.php");
require_once(PHP_WRITEEXCEL_PATH."functions.writeexcel_utility.inc.php");
$this->workbook = new writeexcel_workbookbig($file);
$this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory
$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
$this->worksheet = &$this->workbook->addworksheet();
}
else
{
require_once(PHPEXCEL_PATH."PHPExcel.php");
require_once(PHPEXCEL_PATH."PHPExcel/Style/Alignment.php");
$this->workbook = new PHPExcel();
$this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION);
//$this->workbook->getProperties()->setLastModifiedBy('Dolibarr '.DOL_VERSION);
$this->workbook->getProperties()->setTitle($outputlangs->trans("Export").' - '.$file);
$this->workbook->getProperties()->setSubject($outputlangs->trans("Export").' - '.$file);
$this->workbook->getProperties()->setDescription($outputlangs->trans("Export").' - '.$file);
// $this->worksheet->set_column(0, 50, 18);
$this->workbook->setActiveSheetIndex(0);
$this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
$this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(15);
}
return $ret;
}
/**
* Write header
*
* @param outputlangs Object lang to translate values
*/
function write_header($outputlangs)
{
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
//$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
return 0;
}
@@ -148,23 +172,30 @@ class ExportExcel extends ModeleExports
/**
* Output title line into file
*
* @param array_export_fields_label Array with list of label of fields
* @param array_selected_sorted Array with list of field to export
* @param outputlangs Object lang to translate values
*/
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
{
// Create a format for the column headings
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
// Create a format for the column headings
$formatheader =$this->workbook->addformat();
$formatheader->set_bold();
$formatheader->set_color('blue');
//$formatheader->set_size(12);
//$formatheader->set_font("Courier New");
//$formatheader->set_align('center');
//$this->worksheet->insert_bitmap('A1', 'php.bmp', 16, 8);
}
else
{
$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
$this->col=0;
foreach($array_selected_sorted as $code => $value)
@@ -172,7 +203,14 @@ class ExportExcel extends ModeleExports
$alias=$array_export_fields_label[$code];
//print "dd".$alias;
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
}
else
{
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
}
$this->col++;
}
$this->row++;
@@ -181,24 +219,22 @@ class ExportExcel extends ModeleExports
/**
* Output record line into file
*
* @param array_selected_sorted Array with list of field to export
* @param objp A record from a fetch with all fields from select
* @param outputlangs Object lang to translate values
*/
function write_record($array_selected_sorted,$objp,$outputlangs)
{
// Create a format for the column headings
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
}
$formatdate=$this->workbook->addformat();
$formatdate->set_num_format('yyyy-mm-dd');
//$formatdate->set_num_format(0x0f);
$formatdatehour=$this->workbook->addformat();
$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
//$formatdatehour->set_num_format(0x0f);
// Define first row
$this->col=0;
foreach($array_selected_sorted as $code => $value)
{
$alias=str_replace(array('.','-'),'_',$code);
@@ -219,22 +255,55 @@ class ExportExcel extends ModeleExports
if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
{
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$formatdate=$this->workbook->addformat();
$formatdate->set_num_format('yyyy-mm-dd');
//$formatdate->set_num_format(0x0f);
$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdate);
$this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
}
else
{
$newvalue=dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
}
}
elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
{
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$formatdatehour=$this->workbook->addformat();
$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
//$formatdatehour->set_num_format(0x0f);
$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
}
else
{
$newvalue=dol_stringtotime($newvalue);
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
}
}
else
{
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$this->worksheet->write($this->row, $this->col, $newvalue);
}
else
{
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
}
}
$this->col++;
}
$this->row++;
@@ -242,21 +311,41 @@ class ExportExcel extends ModeleExports
}
/**
* Write footer
*
* @param outputlangs Object lang to translate values
*/
function write_footer($outputlangs)
{
return 0;
}
/**
* Close Excel file
*/
function close_file()
{
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
{
$this->workbook->close();
}
else
{
require_once(PHPEXCEL_PATH."PHPExcel/Writer/Excel5.php");
$objWriter = new PHPExcel_Writer_Excel5($this->workbook);
$objWriter->save($this->file);
$this->workbook->disconnectWorksheets();
unset($this->workbook);
}
return 0;
}
/**
* Clean a cell to respect rules of Excel file cells
*
* @param newvalue String to clean
* @return string Value cleaned
*/

View File

@@ -1,90 +0,0 @@
0.3.0 (2005-11-01):
- Fixed cell merging (fix contributed by Nicolas Kahn - thanks!)
- Corrected the README: formulas are supported since version 0.2.2
- Added a method named set_codepage() to the workbook object which
allows to set the codepage (fixes German Umlauts on Macs for
example, contributed by Stefan Gr<47>nig - thanks!)
- Changed all calls of call_user_method_array() to call_user_func_array()
as recent PHP versions complain about call_user_method_array() being
deprecated (reported by Julien Detante and Luc Cessieux)
- Added $_debug to the class variable declaration of
class.writeexcel_biffwriter.inc.php and
class.writeexcel_worksheet.inc.php so that PHP doesn't complain about it
- The demos now produce proper headers ("Content-Type" and
"Content-Disposition") so that the correct application gets loaded
when an XLS file is received more reliably (thanks to
C. Mourad Jaber)
- Temporary files are now deleted (reported by Siggi Oskarsson)
- Added example-colors.php
- Fixed frozen and thawed panes (reported by Roger Jochem and Flavio
Ciotola)
- Added example-panes.php to prove that it's really fixed ;-)
- Added example-repeat.php because somebody reported that it doesn't
work - it does work for me, please report again if it fails for you
and send me your code
- Fixed cell range formulas like '$A$1:$B$2' which should now work
(thanks Cedric Chandon)
- Fixed the PHP 5 incompatibility (reported by several people, patch
by Jean Pasdeloup, thanks!)
0.2.2 (2003-10-08):
- Cleaned up class.writeexcel_biffwriter.inc.php
- Cleaned up _append() and _prepend() in class.writeexcel_biffwriter.inc.php
and class.writeexcel_worksheet.inc.php to no longer use func_get_args()
but require exactly one argument instead (internal api change)
- Changed class to support tmpfile. Because of this it is possible now to
create an excel sheet on the fly that can be send by web server and is
afterwards deleted. To provoke this behaviour you just pass an empty file
name and later on use the writexcel_workbook->send(filename) function.
(contributed by Andreas Brodowski)
- Imported and changed the PEAR::Spreadsheet Parser.php file to allow
formulas in worksheets (contributed by Andreas Brodowski)
0.2.1 (2002-11-11):
- Corrected two typos in class.writeexcel_format.inc.php
(thanks to Peter van Aarle)
- Fixed cell bg_color (thanks to Jason McCarver for the patch)
- Added support for Big/Little Endian (thanks to Marc Dilasser)
- Added FAQ
- Random cleanups
0.2.0 (2002-09-04):
- Added missing methods set_bg_color(), set_rotation(), set_text_justlast(),
set_locked(), set_hidden(), set_font_script(), set_font_shadow(),
set_font_outline() and set_font_strikeout() to
class.writeexcel_format.inc.php
- Cleaned up class.writeexcel_format.inc.php
- Moved $monthdays() in functions.writeexcel_utility.inc.php into
xl_date_list()
- Fixed all calls to call_user_func_array() and call_user_method_array()
where the first parameter was an undefined constant (thanks Arnaud Limbourg)
- Cleaned up class.writeexcel_olewriter.inc.php
- Temporarily moved class.writeexcel_formula.inc.php out of the archive
because formulas are not yet supported
- Added support for files bigger than 7 MB
(class.writeexcel_workbookbig.inc.php), requires php_ole
- Added example which creates a file bigger than 7 MB (example-bigfile.php)
- Changed dates in CHANGELOG to international notation
- Updated the README file
0.1.2 (2002-08-10):
- Fixed xl_date_list() in class.writeexcel_utility.inc.php
- Cleaned up class.writeexcel_utility.inc.php
- Renamed class.writeexcel_utility.inc.php to
functions.writeexcel_utility.inc.php (it isn't actually a class)
- Changed "pack("NN", 0xD0CF11E0, 0xA1B11AE1)" to
"pack("C8", 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1)"
in class.writeexcel_olewriter.inc.php which seems to work around a bug in
some PHP versions (thanks to Ma<4D>tre Reizz for this one!)
0.1.1 (2002-07-30):
- Fixed several PHP warnings regarding call-time pass-by-reference and
undefined constants
- Changed "Spreadsheet::WriteExcel" to "php_writeexcel" in example-demo.php
- Changed fopen() calls to explicitely open files in binary mode
0.1.0 (2002-05-20):
- Added support for inserting bitmaps (insert_bitmap in writeexcel_worksheet)
- Some fixes for improved compatibility with the Spreadsheet::WriteExcel
examples (see example-*.php)
- Some random bugfixes

View File

@@ -1 +0,0 @@
You can contact me via email at <jonny@nurfuerspam.de>.

View File

@@ -1,33 +0,0 @@
Q: Could you please add support for XYZGJGNDF?
A: Sorry, I don't have the time to make this a full-featured project.
It only contains the features which I need (and which were supported
by SpreadSheet:WriteExcel anyway). You are welcome to add features
yourself though and send it to me for inclusion.
Q: The files class.ole_pps_root.php and class.ole_pps_file.php are
missing. Where can I get them?
A: They are only required for big file (>7 MB) support and available
as a seperate project at
http://bettina-attack.de/jonny/view.php/projects/php_ole/
Q: How can I create files bigger than 7 MB?
A: Use class.writeexcel_workbookbig.inc.php instead of
class.writeexcel_workbook.inc.php. You'll need the php_ole project
available at
http://bettina-attack.de/jonny/view.php/projects/php_ole/
Q: Will you make the project PEAR compliant?
A: Probably. But this means a lot of work and will require some time.
Q: Is there a 'auto-column-width' function?
A: AFAIK Excel doesn't store this information in the XLS files but
calculates the auto-width at run-time, so this doesn't seem to be
possible, sorry.
Q: Is it possible to include Unicode strings in a worksheet?
A: Sorry, this is not possible due to the restrictions of the Excel 5
format which is still used.
Q: Is it possible to include strings with a length of more than
255 characters?
A: No, sorry. Please see the TODO file.

View File

@@ -1,23 +0,0 @@
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/

View File

@@ -1 +0,0 @@
http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

View File

@@ -1,503 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -1,117 +0,0 @@
What is it all about?
---------------------
php_writeexcel is a port of John McNamara's excellent Spreadsheet::WriteExcel
Perl package to PHP. It allows you to generate Microsoft Excel documents on
your PHP enabled Web server without any other tools.
Where to start
--------------
I've included six example PHP scripts which are also taken out of the
Spreadsheet::WriteExcel package and ported to PHP:
- example-simple.php
- example-merge2.php
- example-stocks.php
- example-textwrap.php
- example-demo.php
- example-bigfile.php
All you have to do is to tar xzvf the package to a directory accessible
via a web server. Then fetch any of the example scripts with your
favourite web browser and Excel should come into place and show you
a sheet.
Problems of porting Perl code to PHP
------------------------------------
When you take a first look at both languages, they seem to be very
similar: Variable names begin with a dollar sign, control structures
look like in C. You don't have to change most of these things.
Then, there are things which can be done by find and replace: Perl subs
are functions in PHP. Perl properties like $this->{prop} are $this->prop
in PHP. "elsif" in Perl is "elseif" in PHP. Even porting Perl's so called
OOP is not very difficult: just delete the "my $this=shift;" at the
beginning of each method and then put all the methods into a class {} block.
Just be aware that in Perl not the function declaration decides if the
function is a method or not, but the call of the function. If you say
myfunc(), it's a function, if you say $obj->myfunc(), it's a method.
Then the trouble begins. There were three major things I had problems
with while porting SpreadSheet::WriteExcel to PHP:
- function (sub) handling:
In Perl's list philosophy the number of paramaters and return values
are variable by design: Just use myfunc(@myarray) to pass a complete
array to the function and the array's values will be the function's
arguments.
In PHP this is possible though undesirable as you have to use ugly
things like call_user_function_array() and call_user_method_array()
if you want to translate the Perl code literally.
- Reference juggling:
This can be very confusing when reading Perl code making
excessive use of it. References are supported by PHP, but it's
hard to translate them mainly due to to PHP's habit to copy
EVERYTHING on any assignment. Even if you do a "$obj=new myclass();",
PHP will create a copy of the instantiated class. It's sometimes
hard to recognize when you have to use the "=&" operator to create
a reference instead of a copy. And, hey, when the hell will the
PHP developers implement a foreach loop which assigns the array
values by reference?? :-(
- Perl's AUTOLOAD method - PHP does not have such a thing. When
a class has many properties and the AUTOLOAD method is used
to simulate a set_xxx() for each property, you'll have to define all
possible function calls manually.
What features are currently supported?
--------------------------------------
Basically all features of Spreadsheet::WriteExcel are supported and
thanks to a lot of people (see CHANGELOG) who contributed code and bug
fixes, most things seem to work. However, please remember that it's still
in beta stage, so there are probably some bugs left.
Spreadsheet::WriteExcel uses the Parse::RecDescent package for formula
support. Andreas Brodowski has imported and changed the PEAR::Spreadsheet
Parser.php file, so formulas are supported since version 0.2.2.
Spreadsheet::WriteExcel uses the OLE::Storage_Lite package for
supporting Excel files bigger than approx. 7 MB. I have ported this
package already and called it php_ole. But I really don't know how
reliable it is, so use it with care!
Documentation
-------------
Sorry, there is no documentation yet. You'll have to use the documentation
for Spreadsheet::WriteExcel available at
http://search.cpan.org/doc/JMCNAMARA/Spreadsheet-WriteExcel-0.37/WriteExcel/doc/WriteExcel.html
for now. Try to translate the Perl code into PHP with the help of the
examples. Please note that you have to assign variables by reference
(using the =& operator) quite often!
Reporting bugs
--------------
If you've found a bug, please send a bug report to jonny@nurfuerspam.de.
Please include "php_writeexcel" in the subject so that I can search for bug
reports by searching for that string.
Please note that my email address has changed. Several mails have been lost,
so if you patch didn't get it, please resend it.
If you get error messages, please include them in your report. Please also
check your Apache error_log for messages coming from php_writeexcel.
If you get corrupted Excel files, please include them in your email. If
one of the demos generates a corrupted file please try to find out the
differences between your file and the file you are getting from the
online demo at the php_writeexcel homepage!
Syntax different from SpreadSheet::WriteExcel
---------------------------------------------
The worksheet methods set_h_pagebreaks() and set_v_pagebreaks() take
exactly one argument which must be an array with the desired page breaks.

View File

@@ -1,5 +0,0 @@
Thanks go to John McNamara for his excellent Spreadsheet::WriteExcel
package. Without him, php_writeexcel wouldn't exist.
Also thanks to all people who sent me patches and bug reports (see
the CHANGES file).

View File

@@ -1,9 +0,0 @@
The maximum string length is 255 due to the Excel 5 format which is
still used. The long_string.pl example coming with
SpreadSheet::WriteExcel does not work for some reason. It must be
figured out why.
Volker Sauer has reported that sheet names in Excel files generated by
php_writeexcel get prepended with ".xls]" when he renames them, but I
can't reproduce it. If you can, please send me the generated file and
the version number of Excel you are using.

View File

@@ -1,40 +0,0 @@
<?PHP
require_once "Excel/class.writeexcel_workbook.inc.php";
require_once "Excel/class.writeexcel_worksheet.inc.php";
require_once "Excel/functions.writeexcel_utility.inc.php";
class Excel_Workbook extends writeexcel_workbook {
/**
* The constructor. It just creates a Workbook
*
* @param string $filename The optional filename for the Workbook.
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
*/
function Excel_Workbook($filename = '') {
$this->_filename = $filename;
$this->writeexcel_workbook($filename);
}
/**
* Send HTTP headers for the Excel file.
*
* @param string $filename The filename to use for HTTP headers
* @access public
*/
function send($filename) { // attachment
global $pref_lang;
$this->_tmpfilename = $filename;
/* if ($pref_lang == "ru") {
header ('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
} else {
header ('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">');
}
*/ header("Content-type: application/x-msexcel");
header("Content-Disposition: inline; filename=$filename");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}
}
?>

View File

@@ -1,541 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the OLE::Storage_Lite Perl package ported to PHP
* OLE::Storage_Lite was written by Kawai Takanori, kwitknr@cpan.org
*/
require_once "functions.ole.php";
class ole {
var $sFile;
#------------------------------------------------------------------------------
# new OLE::Storage_Lite
#------------------------------------------------------------------------------
function ole($sFile) {
$this->sFile=$sFile;
}
#------------------------------------------------------------------------------
# getPpsTree: OLE::Storage_Lite
#------------------------------------------------------------------------------
function getPpsTree($bData=false) {
#0.Init
$rhInfo = _initParse($this->_FILE);
if (!$rhInfo) {
return false;
}
#1. Get Data
list($oPps) = _getPpsTree(0, $rhInfo, $bData);
// close(IN);
return $oPps;
}
#------------------------------------------------------------------------------
# getSearch: OLE::Storage_Lite
#------------------------------------------------------------------------------
function getPpsSearch($raName, $bData=false, $iCase=false) {
#0.Init
$rhInfo = _initParse($this->_FILE);
if (!$rhInfo) {
return false;
}
#1. Get Data
$aList = _getPpsSearch(0, $rhInfo, $raName, $bData, $iCase);
// close(IN);
return $aList;
}
#------------------------------------------------------------------------------
# getNthPps: OLE::Storage_Lite
#------------------------------------------------------------------------------
function getNthPps($iNo, $bData=false) {
#0.Init
$rhInfo = _initParse($this->_FILE);
if (!$rhInfo) {
return false;
}
#1. Get Data
$oPps = _getNthPps($iNo, $rhInfo, $bData);
// close IN;
return $oPps;
}
#------------------------------------------------------------------------------
# _initParse: OLE::Storage_Lite
#------------------------------------------------------------------------------
function _initParse($sFile) {
//$oIo;
#1. $sFile is a resource (hopefully a file resource)
if (is_resource($sFile)) {
$oIo=$sFile;
}
#2. $sFile is a filename string
else {
$oIo=fopen($sFile, "rb");
}
return _getHeaderInfo($oIo);
}
#------------------------------------------------------------------------------
# _getPpsTree: OLE::Storage_Lite
#------------------------------------------------------------------------------
function _getPpsTree($iNo, $rhInfo, $bData, &$raDone) { // last par optional!
if($raDone!==false) {
if(in_array($iNo, $raDone)) {
return array();
}
} else {
$raDone=array();
}
array_push($raDone, $iNo);
$iRootBlock = $rhInfo->_ROOT_START;
#1. Get Information about itself
$oPps = _getNthPps($iNo, $rhInfo, $bData);
#2. Child
if($oPps->DirPps != 0xFFFFFFFF) {
$aChildL = _getPpsTree($oPps->DirPps, $rhInfo, $bData, $raDone);
$oPps->Child =& $aChildL;
} else {
$oPps->Child = false;
}
#3. Previous,Next PPSs
$aList = array();
if ($oPps->PrevPps != 0xFFFFFFFF) {
array_push($aList, _getPpsTree($oPps->PrevPps, $rhInfo, $bData, $raDone));
}
array_push($aList, $oPps);
if ($oPps->NextPps != 0xFFFFFFFF) {
array_push($aList, _getPpsTree($oPps->NextPps, $rhInfo, $bData, $raDone));
}
return $aList;
}
#------------------------------------------------------------------------------
# _getPpsSearch: OLE::Storage_Lite
#------------------------------------------------------------------------------
function _getPpsSearch($iNo, $rhInfo, $raName, $bData, $iCase, &$raDone) { // last par optional!
$iRootBlock = $rhInfo->_ROOT_START;
//my @aRes;
#1. Check it self
if($raDone!==false) {
if(in_array($iNo, $raDone)) {
return array();
}
} else {
$raDone=array();
}
array_push($raDone, $iNo);
$oPps = _getNthPps($iNo, $rhInfo, false);
$found=false;
foreach ($raName as $cmp) {
if (($iCase && strcasecmp($oPps->Name, $cmp)==0) ||
strcmp($oPps->Name, $cmp)==0) {
$found=true;
break;
}
}
if ($found) {
if ($bData) {
$oPps = _getNthPps($iNo, $rhInfo, $bData);
}
$aRes = array($oPps);
} else {
$aRes = array();
}
#2. Check Child, Previous, Next PPSs
if ($oPps->DirPps != 0xFFFFFFFF) {
array_push($aRes, _getPpsSearch($oPps->DirPps, $rhInfo, $raName, $bData, $iCase, $raDone));
}
if ($oPps->PrevPps != 0xFFFFFFFF) {
array_push($aRes, _getPpsSearch($oPps->PrevPps, $rhInfo, $raName, $bData, $iCase, $raDone));
}
if ($oPps->NextPps != 0xFFFFFFFF) {
array_push($aRes, _getPpsSearch($oPps->NextPps, $rhInfo, $raName, $bData, $iCase, $raDone));
}
return $aRes;
}
#===================================================================
# Get Header Info (BASE Informain about that file)
#===================================================================
function _getHeaderInfo($FILE) {
//my($iWk);
$rhInfo = new object();
$rhInfo->_FILEH_ = $FILE;
//my $sWk;
#0. Check ID
fseek($rhInfo->_FILEH_, 0, SEEK_SET);
$sWk=fread($rhInfo->_FILEH_, 8);
if ($sWk!="\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1") {
return false;
}
#BIG BLOCK SIZE
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x1E, 2, "v");
if ($iWk===false) {
return false;
}
$rhInfo->_BIG_BLOCK_SIZE = pow(2, $iWk);
#SMALL BLOCK SIZE
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x20, 2, "v");
if ($iWk===false) {
return false;
}
$rhInfo->_SMALL_BLOCK_SIZE = pow(2, $iWk);
#BDB Count
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x2C, 4, "V");
if ($iWk===false) {
return false;
}
$rhInfo->_BDB_COUNT = $iWk;
#START BLOCK
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x30, 4, "V");
if ($iWk===false) {
return false;
}
$rhInfo->_ROOT_START = $iWk;
#MIN SIZE OF BB
# $iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x38, 4, "V");
# if ($iWk===false) {
# return false;
# }
# $rhInfo->_MIN_SIZE_BB = $iWk;
#SMALL BD START
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x3C, 4, "V");
if ($iWk===false) {
return false;
}
$rhInfo->_SBD_START = $iWk;
#SMALL BD COUNT
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x40, 4, "V");
if ($iWk===false) {
return false;
}
$rhInfo->_SBD_COUNT = $iWk;
#EXTRA BBD START
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x44, 4, "V");
if ($iWk===false) {
return false;
}
$rhInfo->_EXTRA_BBD_START = $iWk;
#EXTRA BD COUNT
$iWk = _getInfoFromFile($rhInfo->_FILEH_, 0x48, 4, "V");
if ($iWk===false) {
return false;
}
$rhInfo->_EXTRA_BBD_COUNT = $iWk;
#GET BBD INFO
$rhInfo->_BBD_INFO= _getBbdInfo($rhInfo);
#GET ROOT PPS
$oRoot = _getNthPps(0, $rhInfo, false);
$rhInfo->_SB_START = $oRoot->StartBlock;
$rhInfo->_SB_SIZE = $oRoot->Size;
return $rhInfo;
}
#------------------------------------------------------------------------------
# _getInfoFromFile
#------------------------------------------------------------------------------
function _getInfoFromFile($FILE, $iPos, $iLen, $sFmt) {
//my($sWk);
if (!$FILE) {
return false;
}
if (fseek($FILE, $iPos, SEEK_SET)!==0) {
return false;
}
$sWk=fread($FILE, $iLen);
$data=unpack($sFmt."ret", $sWk);
return $data["ret"];
}
#------------------------------------------------------------------------------
# _getBbdInfo
#------------------------------------------------------------------------------
function _getBbdInfo($rhInfo) {
$aBdList = array();
$iBdbCnt = $rhInfo->_BDB_COUNT;
//my $iGetCnt;
//my $sWk;
$i1stCnt = floor(($rhInfo->_BIG_BLOCK_SIZE - 0x4C) / LongIntSize);
$iBdlCnt = floor($rhInfo->_BIG_BLOCK_SIZE / LongIntSize) - 1;
#1. 1st BDlist
fseek ($rhInfo->_FILEH_, 0x4C, SEEK_SET);
$iGetCnt = ($iBdbCnt < $i1stCnt) ? $iBdbCnt : $i1stCnt;
$sWk=fread($rhInfo->_FILEH_, LongIntSize*$iGetCnt);
$data=unpack("V".$iGetCnt."int", $sWk);
for ($c=0;$c<$iGetCnt;$c++) {
array_push ($aBdList, $data["int$c"]);
}
$iBdbCnt -= $iGetCnt;
#2. Extra BDList
$iBlock = $rhInfo->_EXTRA_BBD_START;
while(($iBdbCnt> 0) && _isNormalBlock($iBlock)){
_setFilePos($iBlock, 0, $rhInfo);
$iGetCnt= ($iBdbCnt < $iBdlCnt) ? $iBdbCnt : $iBdlCnt;
$sWk=fread($rhInfo->_FILEH_, LongIntSize*$iGetCnt);
$data=unpack("V".$iGetCnt."int", $sWk);
for ($c=0;$c<$iGetCnt;$c++) {
array_push ($aBdList, $data["int$c"]);
}
$iBdbCnt -= $iGetCnt;
$sWk=fread($rhInfo->_FILEH_, LongIntSize);
$data=unpack("Vint", $sWk);
$iBlock = $data["int"];
}
#3.Get BDs
$aWk=array();
$hBd=array();
$iBlkNo = 0;
//my $iBdL;
//my $i;
$iBdCnt = floor($rhInfo->_BIG_BLOCK_SIZE / LongIntSize);
foreach ($aBdList as $iBdl) {
// foreach $iBdL (@aBdList) {
_setFilePos($iBdL, 0, $rhInfo);
$sWk=fread($rhInfo->_FILEH_, $rhInfo->_BIG_BLOCK_SIZE);
$aWk = unpack("V".$iBdCnt."int", $sWk);
for ($i=0;$i<$iBdCnt;$i++, $iBlkNo++) {
if($aWk["int".$i] != ($iBlkNo+1)) {
$hBd["$iBlkNo"] = $aWk["int".$i];
}
}
}
return $hBd;
}
#------------------------------------------------------------------------------
# getNthPps (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _getNthPps($iPos, $rhInfo, $bData) {
$iPpsStart = $rhInfo->_ROOT_START;
//my($iPpsBlock, $iPpsPos);
//my $sWk;
//my $iBlock;
$iBaseCnt = $rhInfo->_BIG_BLOCK_SIZE / PpsSize;
$iPpsBlock = floor($iPos / $iBaseCnt);
$iPpsPos = $iPos % $iBaseCnt;
$iBlock = _getNthBlockNo($iPpsStart, $iPpsBlock, $rhInfo);
if ($iBlock===false) {
return false;
}
_setFilePos($iBlock, PpsSize*$iPpsPos, $rhInfo);
$sWk=fread($rhInfo->_FILEH_, PpsSize);
// return undef unless($sWk);
//TODO: substr() binary safe?
$data=unpack("vint", substr($sWk, 0x40, 2));
$iNmSize = $data["int"];
$iNmSize = ($iNmSize > 2) ? $iNmSize - 2 : $iNmSize;
$sNm= substr($sWk, 0, $iNmSize);
$data=unpack("Cint", substr($sWk, 0x42, 2));
$iType = $data["int"];
$data=unpack("V3int", substr($sWk, 0x44, LongIntSize*3));
$lPpsPrev = $data["int1"];
$lPpsNext = $data["int2"];
$lDirPps = $data["int3"];
// TODO: Original lines terminated by commas: ?!
/*
my @raTime1st =
(($iType == PpsType_Root) or ($iType == PpsType_Dir))?
OLEDate2Local(substr($sWk, 0x64, 8)) : undef ,
my @raTime2nd =
(($iType == PpsType_Root) or ($iType == PpsType_Dir))?
OLEDate2Local(substr($sWk, 0x6C, 8)) : undef,
*/
$raTime1st = (($iType == PpsType_Root) or ($iType == PpsType_Dir)) ?
OLEDate2Local(substr($sWk, 0x64, 8)) : false;
$raTime2nd = (($iType == PpsType_Root) or ($iType == PpsType_Dir)) ?
OLEDate2Local(substr($sWk, 0x6C, 8)) : false;
$data=unpack("V2int", substr($sWk, 0x74, 8));
$iStart=$data["int1"];
$iSize=$data["int2"];
if ($bData) {
$sData = _getData($iType, $iStart, $iSize, $rhInfo);
/* TODO!!!
return OLE::Storage_Lite::PPS->new(
$iPos, $sNm, $iType, $lPpsPrev, $lPpsNext, $lDirPps,
\@raTime1st, \@raTime2nd, $iStart, $iSize, $sData, undef);
*/
} else {
/* TODO!!!
return OLE::Storage_Lite::PPS->new(
$iPos, $sNm, $iType, $lPpsPrev, $lPpsNext, $lDirPps,
\@raTime1st, \@raTime2nd, $iStart, $iSize, undef, undef);
*/
}
}
#------------------------------------------------------------------------------
# _setFilePos (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _setFilePos($iBlock, $iPos, $rhInfo) {
fseek($rhInfo->_FILEH_, ($iBlock+1)*$rhInfo->_BIG_BLOCK_SIZE+$iPos,
SEEK_SET);
}
#------------------------------------------------------------------------------
# _getNthBlockNo (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _getNthBlockNo($iStBlock, $iNth, $rhInfo) {
//my $iSv;
$iNext = $iStBlock;
for ($i=0; $i<$iNth; $i++) {
$iSv = $iNext;
$iNext = _getNextBlockNo($iSv, $rhInfo);
if (!_isNormalBlock($iNext)) {
return;
}
}
return $iNext;
}
#------------------------------------------------------------------------------
# _getData (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _getData($iType, $iBlock, $iSize, $rhInfo) {
if ($iType == PpsType_File) {
if($iSize < DataSizeSmall) {
return _getSmallData($iBlock, $iSize, $rhInfo);
} else {
return _getBigData($iBlock, $iSize, $rhInfo);
}
} elseif($iType == PpsType_Root) { #Root
return _getBigData($iBlock, $iSize, $rhInfo);
} elseif($iType == PpsType_Dir) { # Directory
return false;
}
}
#------------------------------------------------------------------------------
# _getBigData (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _getBigData($iBlock, $iSize, $rhInfo) {
//my($iRest, $sWk, $sRes);
if (!_isNormalBlock($iBlock)) {
return '';
}
$iRest = $iSize;
//my($i, $iGetSize, $iNext);
$sRes = '';
/* TODO
my @aKeys= sort({$a<=>$b} keys(%{$rhInfo->{_BBD_INFO}}));
while ($iRest > 0) {
my @aRes = grep($_ >= $iBlock, @aKeys);
my $iNKey = $aRes[0];
$i = $iNKey - $iBlock;
$iNext = $rhInfo->{_BBD_INFO}{$iNKey};
_setFilePos($iBlock, 0, $rhInfo);
my $iGetSize = ($rhInfo->{_BIG_BLOCK_SIZE} * ($i+1));
$iGetSize = $iRest if($iRest < $iGetSize);
$rhInfo->{_FILEH_}->read( $sWk, $iGetSize);
$sRes .= $sWk;
$iRest -= $iGetSize;
$iBlock= $iNext;
}
*/
return $sRes;
}
#------------------------------------------------------------------------------
# _getNextBlockNo (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _getNextBlockNo($iBlockNo, $rhInfo) {
$iRes = $rhInfo->_BBD_INFO[$iBlockNo];
return ($iRes!==false) ? $iRes : $iBlockNo+1;
}
#------------------------------------------------------------------------------
# _isNormalBlock (OLE::Storage_Lite)
# 0xFFFFFFFC : BDList, 0xFFFFFFFD : BBD,
# 0xFFFFFFFE: End of Chain 0xFFFFFFFF : unused
#------------------------------------------------------------------------------
function _isNormalBlock($iBlock) {
return ($iBlock < 0xFFFFFFFC) ? 1 : false;
}
#------------------------------------------------------------------------------
# _getSmallData (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _getSmallData($iSmBlock, $iSize, $rhInfo) {
//my($sRes, $sWk);
$iRest = $iSize;
$sRes = '';
while ($iRest > 0) {
_setFilePosSmall($iSmBlock, $rhInfo);
$sWk=fread($rhInfo->_FILEH_, ($iRest >= $rhInfo->_SMALL_BLOCK_SIZE) ?
$rhInfo->_SMALL_BLOCK_SIZE : $iRest);
$sRes .= $sWk;
$iRest -= $rhInfo->_SMALL_BLOCK_SIZE;
$iSmBlock= _getNextSmallBlockNo($iSmBlock, $rhInfo);
}
return $sRes;
}
#------------------------------------------------------------------------------
# _setFilePosSmall(OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _setFilePosSmall($iSmBlock, $rhInfo) {
$iSmStart = $rhInfo->_SB_START;
$iBaseCnt = $rhInfo->_BIG_BLOCK_SIZE / $rhInfo->_SMALL_BLOCK_SIZE;
$iNth = floor($iSmBlock/$iBaseCnt);
$iPos = $iSmBlock % $iBaseCnt;
$iBlk = _getNthBlockNo($iSmStart, $iNth, $rhInfo);
_setFilePos($iBlk, $iPos * $rhInfo->_SMALL_BLOCK_SIZE, $rhInfo);
}
#------------------------------------------------------------------------------
# _getNextSmallBlockNo (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _getNextSmallBlockNo($iSmBlock, $rhInfo) {
//my($sWk);
$iBaseCnt = $rhInfo->_BIG_BLOCK_SIZE / LongIntSize;
$iNth = floor($iSmBlock/$iBaseCnt);
$iPos = $iSmBlock % $iBaseCnt;
$iBlk = _getNthBlockNo($rhInfo->_SBD_START, $iNth, $rhInfo);
_setFilePos($iBlk, $iPos * LongIntSize, $rhInfo);
$sWk=fread($rhInfo->_FILEH_, LongIntSize);
$data=unpack("Vint", $sWk);
return $data["int"];
}
}
?>

View File

@@ -1,209 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the OLE::Storage_Lite Perl package ported to PHP
* OLE::Storage_Lite was written by Kawai Takanori, kwitknr@cpan.org
*/
class ole_pps {
var $No;
var $Name;
var $Type;
var $PrevPps;
var $NextPps;
var $DirPps;
var $Time1st;
var $Time2nd;
var $StartBlock;
var $Size;
var $Data;
var $Child;
#------------------------------------------------------------------------------
# new (OLE::Storage_Lite::PPS)
#------------------------------------------------------------------------------
// TODO: Do we need this function?
/*
function ole_pps($iNo, $sNm, $iType, $iPrev, $iNext, $iDir,
$raTime1st, $raTime2nd, $iStart, $iSize,
$sData=false, $raChild=false) {
#1. Constructor for General Usage
if($iType == PpsType_File) { #FILE
return OLE::Storage_Lite::PPS::File->_new
($iNo, $sNm, $iType, $iPrev, $iNext, $iDir, $raTime1st, $raTime2nd,
$iStart, $iSize, $sData, $raChild);
}
elsif($iType == PpsType_Dir) { #DIRECTRY
return OLE::Storage_Lite::PPS::Dir->_new
($iNo, $sNm, $iType, $iPrev, $iNext, $iDir, $raTime1st, $raTime2nd,
$iStart, $iSize, $sData, $raChild);
}
elsif($iType == PpsType_Root) { #ROOT
return OLE::Storage_Lite::PPS::Root->_new
($iNo, $sNm, $iType, $iPrev, $iNext, $iDir, $raTime1st, $raTime2nd,
$iStart, $iSize, $sData, $raChild);
}
else {
die "Error PPS:$iType $sNm\n";
}
}
*/
// We probably don't need a constructor at all because
// all derived classed do their own initialization stuff
#------------------------------------------------------------------------------
# _new (OLE::Storage_Lite::PPS)
# for OLE::Storage_Lite
#------------------------------------------------------------------------------
function ole_pps($iNo, $sNm, $iType, $iPrev, $iNext, $iDir,
$raTime1st, $raTime2nd, $iStart, $iSize,
$sData=false, $raChild=false) {
#1. Constructor for OLE::Storage_Lite
$this->No = $iNo;
$this->Name = $sNm;
$this->Type = $iType;
$this->PrevPps = $iPrev;
$this->NextPps = $iNext;
$this->DirPps = $iDir;
$this->Time1st = $raTime1st;
$this->Time2nd = $raTime2nd;
$this->StartBlock = $iStart;
$this->Size = $iSize;
$this->Data = $sData;
$this->Child = $raChild;
}
#------------------------------------------------------------------------------
# _DataLen (OLE::Storage_Lite::PPS)
# Check for update
#------------------------------------------------------------------------------
function _DataLen() {
if ($this->Data===false) {
return 0;
}
if ($this->_PPS_FILE) {
return filesize($this->_PPS_FILE);
}
return strlen($this->Data);
}
#------------------------------------------------------------------------------
# _makeSmallData (OLE::Storage_Lite::PPS)
#------------------------------------------------------------------------------
function _makeSmallData(&$aList, $rhInfo) {
//my ($sRes);
$FILE = $rhInfo->_FILEH_;
$iSmBlk = 0;
for ($c=0;$c<sizeof($aList);$c++) {
$oPps=&$aList[$c];
#1. Make SBD, small data string
if ($oPps->Type==PpsType_File) {
if ($oPps->Size<=0) {
continue;
}
if($oPps->Size < $rhInfo->_SMALL_SIZE) {
$iSmbCnt = floor($oPps->Size / $rhInfo->_SMALL_BLOCK_SIZE) +
(($oPps->Size % $rhInfo->_SMALL_BLOCK_SIZE) ? 1 : 0);
#1.1 Add to SBD
for ($i = 0; $i<($iSmbCnt-1); $i++) {
fputs($FILE, pack("V", $i+$iSmBlk+1));
}
fputs($FILE, pack("V", -2));
#1.2 Add to Data String(this will be written for RootEntry)
#Check for update
if ($oPps->_PPS_FILE) {
//my $sBuff;
fseek($oPps->_PPS_FILE, 0, SEEK_SET); #To The Top
while ($sBuff=fread($oPps->_PPS_FILE, 4096)) {
$sRes .= $sBuff;
}
} else {
$sRes .= $oPps->Data;
}
if($oPps->Size % $rhInfo->_SMALL_BLOCK_SIZE) {
$sRes .= (str_repeat("\x00",
($rhInfo->_SMALL_BLOCK_SIZE -
($oPps->Size % $rhInfo->_SMALL_BLOCK_SIZE))));
}
#1.3 Set for PPS
$oPps->StartBlock = $iSmBlk;
$iSmBlk += $iSmbCnt;
}
}
}
$iSbCnt = floor($rhInfo->_BIG_BLOCK_SIZE / LongIntSize);
if ($iSmBlk % $iSbCnt) {
fputs($FILE, str_repeat(pack("V", -1), $iSbCnt - ($iSmBlk % $iSbCnt)));
}
#2. Write SBD with adjusting length for block
return $sRes;
}
#------------------------------------------------------------------------------
# _savePpsWk (OLE::Storage_Lite::PPS)
#------------------------------------------------------------------------------
function _savePpsWk($rhInfo) {
#1. Write PPS
$FILE=$rhInfo->_FILEH_;
fputs($FILE,
$this->Name.
str_repeat("\x00", 64 - strlen($this->Name)). # 64
pack("v", strlen($this->Name) + 2). # 66
pack("c", $this->Type). # 67
pack("c", 0x00). #UK # 68
pack("V", $this->PrevPps). #Prev # 72
pack("V", $this->NextPps). #Next # 76
pack("V", $this->DirPps). #Dir # 80
"\x00\x09\x02\x00". # 84
"\x00\x00\x00\x00". # 88
"\xc0\x00\x00\x00". # 92
"\x00\x00\x00\x46". # 96
"\x00\x00\x00\x00". # 100
//TODO!!! LocalDate2OLE($this->Time1st). # 108
"\x00\x00\x00\x00\x00\x00\x00\x00".
//TODO!!! LocalDate2OLE($this->Time2nd). # 116
"\x00\x00\x00\x00\x00\x00\x00\x00".
pack("V", ($this->StartBlock!==false) ?
$this->StartBlock : 0). # 120
pack("V", ($this->Size!==false) ?
$this->Size : 0). # 124
pack("V", 0) # 128
);
}
}
?>

View File

@@ -1,50 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the OLE::Storage_Lite Perl package ported to PHP
* OLE::Storage_Lite was written by Kawai Takanori, kwitknr@cpan.org
*/
require_once "class.ole_pps.php";
require_once "functions.ole.php";
class ole_pps_dir extends ole_pps {
function ole_pps_dir($sName, $raTime1st=false, $raTime2nd=false,
$raChild=false) {
$this->No = false;
$this->Name = $sName;
$this->Type = PpsType_Dir;
$this->PrevPps = false;
$this->NextPps = false;
$this->DirPps = false;
$this->Time1st = $raTime1st;
$this->Time2nd = $raTime2nd;
$this->StartBlock = false;
$this->Size = false;
$this->Data = false;
$this->Child = $raChild;
}
}
?>

View File

@@ -1,74 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the OLE::Storage_Lite Perl package ported to PHP
* OLE::Storage_Lite was written by Kawai Takanori, kwitknr@cpan.org
*/
require_once "class.ole_pps.php";
require_once "functions.ole.php";
class ole_pps_file extends ole_pps {
function ole_pps_file($sNm, $sData=false, $sFile=false) {
$this->No = false;
$this->Name = $sNm;
$this->Type = PpsType_File;
$this->PrevPps = false;
$this->NextPps = false;
$this->DirPps = false;
$this->Time1st = false;
$this->Time2nd = false;
$this->StartBlock = false;
$this->Size = false;
$this->Data = ($sFile===false) ? $sData : '';
$this->Child = false;
if ($sFile!==false) {
if (is_ressource($sFile)) {
$this->_PPS_FILE=$sFile;
} elseif ($sFile=="") {
$fname=tempnam("php_ole");
$this->_PPS_FILE=fopen($fname, "r+b");
} else {
$fname=$sFile;
$this->_PPS_FILE=fopen($fname, "r+b");
}
if ($sData!==false) {
fputs($this->_PPS_FILE, $sData);
}
}
}
function append ($sData) {
if ($this->_PPS_FILE) {
fputs($this->_PPS_FILE, $sData);
} else {
$this->Data.=$sData;
}
}
}
?>

View File

@@ -1,517 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the OLE::Storage_Lite Perl package ported to PHP
* OLE::Storage_Lite was written by Kawai Takanori, kwitknr@cpan.org
*/
require_once "class.ole_pps.php";
require_once "functions.ole.php";
class ole_pps_root extends ole_pps {
function ole_pps_root($raTime1st=false, $raTime2nd=false, $raChild=false) {
$this->No = false;
$this->Name = Asc2Ucs('Root Entry');
$this->Type = PpsType_Root;
$this->PrevPps = false;
$this->NextPps = false;
$this->DirPps = false;
$this->Time1st = $raTime1st;
$this->Time2nd = $raTime2nd;
$this->StartBlock = false;
$this->Size = false;
$this->Data = false;
$this->Child = $raChild;
}
#------------------------------------------------------------------------------
# save (OLE::Storage_Lite::PPS::Root)
#------------------------------------------------------------------------------
function save($sFile, $bNoAs=false, $rhInfo=false) {
#0.Initial Setting for saving
/*
if (!$rhInfo) {
$rhInfo=new object();
}
*/
$rhInfo->_BIG_BLOCK_SIZE=pow(2, (($rhInfo->_BIG_BLOCK_SIZE) ?
_adjust2($rhInfo->_BIG_BLOCK_SIZE) : 9));
$rhInfo->_SMALL_BLOCK_SIZE=pow(2, (($rhInfo->_SMALL_BLOCK_SIZE) ?
_adjust2($rhInfo->_SMALL_BLOCK_SIZE) : 6));
$rhInfo->_SMALL_SIZE = 0x1000;
$rhInfo->_PPS_SIZE = 0x80;
#1.Open File
#1.1 $sFile is Ref of scalar
if(is_resource($sFile)) {
$oIo=$sFile;
$rhInfo->_FILEH_ = $oIo;
}
#1.2 $sFile is a simple filename string
else {
$oIo=fopen("$sFile", "wb");
$rhInfo->_FILEH_ = $oIo;
}
$iBlk = 0;
#1. Make an array of PPS (for Save)
$aList=array();
$list=array(&$this);
if($bNoAs) {
$this->_savePpsSetPnt2($list, $aList, $rhInfo);
} else {
$this->_savePpsSetPnt($list, $aList, $rhInfo);
}
list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList, $rhInfo);
#2.Save Header
$this->_saveHeader($rhInfo, $iSBDcnt, $iBBcnt, $iPPScnt);
#3.Make Small Data string (write SBD)
$sSmWk = $this->_makeSmallData($aList, $rhInfo);
$this->Data = $sSmWk; #Small Datas become RootEntry Data
#4. Write BB
$iBBlk = $iSBDcnt;
$this->_saveBigData($iBBlk, $aList, $rhInfo);
#5. Write PPS
$this->_savePps($aList, $rhInfo);
#6. Write BD and BDList and Adding Header informations
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt, $rhInfo);
#7.Close File
fclose($rhInfo->_FILEH_);
}
#------------------------------------------------------------------------------
# _calcSize (OLE::Storage_Lite::PPS)
#------------------------------------------------------------------------------
function _calcSize(&$raList, $rhInfo) {
#0. Calculate Basic Setting
$iSBDcnt=0;
$iBBcnt=0;
$iPPScnt = 0;
$iSmallLen = 0;
$iSBcnt = 0;
for ($c=0;$c<sizeof($raList);$c++) {
$oPps=&$raList[$c];
if($oPps->Type==PpsType_File) {
$oPps->Size = $oPps->_DataLen(); #Mod
if($oPps->Size < $rhInfo->_SMALL_SIZE) {
$iSBcnt += floor($oPps->Size / $rhInfo->_SMALL_BLOCK_SIZE) +
(($oPps->Size % $rhInfo->_SMALL_BLOCK_SIZE) ? 1 : 0);
} else {
$iBBcnt +=
(floor($oPps->Size/ $rhInfo->_BIG_BLOCK_SIZE) +
(($oPps->Size % $rhInfo->_BIG_BLOCK_SIZE)? 1: 0));
}
}
}
$iSmallLen = $iSBcnt * $rhInfo->_SMALL_BLOCK_SIZE;
$iSlCnt = floor($rhInfo->_BIG_BLOCK_SIZE / LongIntSize);
$iSBDcnt = floor($iSBcnt / $iSlCnt)+ (($iSBcnt % $iSlCnt) ? 1 : 0);
$iBBcnt += (floor($iSmallLen/ $rhInfo->_BIG_BLOCK_SIZE) +
(( $iSmallLen% $rhInfo->_BIG_BLOCK_SIZE) ? 1 : 0));
$iCnt = sizeof($raList);
$iBdCnt = $rhInfo->_BIG_BLOCK_SIZE/PpsSize;
$iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt) ? 1 : 0));
return array($iSBDcnt, $iBBcnt, $iPPScnt);
}
#------------------------------------------------------------------------------
# _adjust2 (OLE::Storage_Lite::PPS::Root)
#------------------------------------------------------------------------------
function _adjust2($i2) {
$iWk = log($i2)/log(2);
return ($iWk > int($iWk)) ? floor($iWk)+1 : $iWk;
}
#------------------------------------------------------------------------------
# _saveHeader (OLE::Storage_Lite::PPS::Root)
#------------------------------------------------------------------------------
function _saveHeader($rhInfo, $iSBDcnt, $iBBcnt, $iPPScnt) {
$FILE = $rhInfo->_FILEH_;
#0. Calculate Basic Setting
$iBlCnt = $rhInfo->_BIG_BLOCK_SIZE / LongIntSize;
$i1stBdL = ($rhInfo->_BIG_BLOCK_SIZE - 0x4C) / LongIntSize;
$iBdExL = 0;
$iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
$iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt) ? 1 : 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt) ? 1 : 0);
//my $i;
#0.1 Calculate BD count
if ($iBdCnt > $i1stBdL) {
// TODO: is do-while correct here?
do {
$iBdExL++;
$iAllW++;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt) ? 1 : 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt) ? 1 : 0);
} while($iBdCnt > ($iBdExL*$iBlCnt+ $i1stBdL));
}
#1.Save Header
fputs($FILE,
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1".
"\x00\x00\x00\x00".
"\x00\x00\x00\x00".
"\x00\x00\x00\x00".
"\x00\x00\x00\x00".
pack("v", 0x3b).
pack("v", 0x03).
pack("v", -2).
pack("v", 9).
pack("v", 6).
pack("v", 0).
"\x00\x00\x00\x00".
"\x00\x00\x00\x00".
pack("V", $iBdCnt).
pack("V", $iBBcnt+$iSBDcnt). #ROOT START
pack("V", 0).
pack("V", 0x1000).
pack("V", 0). #Small Block Depot
pack("V", 1)
);
#2. Extra BDList Start, Count
if($iBdCnt < $i1stBdL) {
fputs($FILE,
pack("V", -2). #Extra BDList Start
pack("V", 0) #Extra BDList Count
);
} else {
fputs($FILE,
pack("V", $iAll+$iBdCnt).
pack("V", $iBdExL)
);
}
#3. BDList
for ($i=0;($i<$i1stBdL) && ($i < $iBdCnt); $i++) {
fputs($FILE, pack("V", $iAll+$i));
}
if ($i<$i1stBdL) {
// TODO: Check, if str_repeat is binary safe
fputs($FILE, str_repeat((pack("V", -1)), ($i1stBdL-$i)));
}
}
#------------------------------------------------------------------------------
# _saveBigData (OLE::Storage_Lite::PPS)
#------------------------------------------------------------------------------
function _saveBigData(&$iStBlk, &$raList, $rhInfo) {
//return;//!!!
$iRes = 0;
$FILE = $rhInfo->_FILEH_;
#1.Write Big (ge 0x1000) Data into Block
for ($c=0;$c<sizeof($raList);$c++) {
$oPps=&$raList[$c];
if($oPps->Type!=PpsType_Dir) {
#print "PPS: $oPps DEF:", defined($oPps->{Data}), "\n";
$oPps->Size = $oPps->_DataLen(); #Mod
if(($oPps->Size >= $rhInfo->_SMALL_SIZE) ||
(($oPps->Type == PpsType_Root) && $oPps->Data!==false)) {
#1.1 Write Data
#Check for update
if($oPps->_PPS_FILE) {
//my $sBuff;
$iLen = 0;
fseek($oPps->_PPS_FILE, 0, SEEK_SET); #To The Top
while ($sBuff=fread($oPps->_PPS_FILE, 4096)) {
$iLen += length($sBuff);
fputs($FILE, $sBuff); #Check for update
}
} else {
fputs($FILE, $oPps->Data);
}
if ($oPps->Size % $rhInfo->_BIG_BLOCK_SIZE) {
// TODO: Check, if str_repeat() is binary safe
fputs($FILE, str_repeat("\x00",
($rhInfo->_BIG_BLOCK_SIZE -
($oPps->Size % $rhInfo->_BIG_BLOCK_SIZE)))
);
}
#1.2 Set For PPS
$oPps->StartBlock = $iStBlk;
$iStBlk +=
(floor($oPps->Size/ $rhInfo->_BIG_BLOCK_SIZE) +
(($oPps->Size % $rhInfo->_BIG_BLOCK_SIZE) ? 1 : 0));
}
}
}
}
#------------------------------------------------------------------------------
# _savePps (OLE::Storage_Lite::PPS::Root)
#------------------------------------------------------------------------------
function _savePps(&$raList, $rhInfo)
{
#0. Initial
$FILE = $rhInfo->_FILEH_;
#2. Save PPS
for ($c=0;$c<sizeof($raList);$c++) {
$oItem=&$raList[$c];
$oItem->_savePpsWk($rhInfo);
}
#3. Adjust for Block
$iCnt = sizeof($raList);
$iBCnt = $rhInfo->_BIG_BLOCK_SIZE / $rhInfo->_PPS_SIZE;
if($iCnt % $iBCnt) {
fputs($FILE, str_repeat("\x00", (($iBCnt - ($iCnt % $iBCnt)) * $rhInfo->_PPS_SIZE)));
}
return (floor($iCnt / $iBCnt) + (($iCnt % $iBCnt) ? 1 : 0));
}
#------------------------------------------------------------------------------
# _savePpsSetPnt2 (OLE::Storage_Lite::PPS::Root)
# For Test
#------------------------------------------------------------------------------
function _savePpsSetPnt2(&$aThis, &$raList, $rhInfo) {
#1. make Array as Children-Relations
#1.1 if No Children
if (!is_array($aThis) || sizeof($aThis)==0) {
return 0xFFFFFFFF;
} elseif (sizeof($aThis)==1) {
#1.2 Just Only one
array_push($raList, $aThis[0]);
$aThis[0]->No = sizeof($raList)-1;
$aThis[0]->PrevPps = 0xFFFFFFFF;
$aThis[0]->NextPps = 0xFFFFFFFF;
$aThis[0]->DirPps = $this->_savePpsSetPnt2($aThis[0]->Child, $raList, $rhInfo);
return $aThis[0]->No;
} else {
#1.3 Array
$iCnt = sizeof($aThis);
#1.3.1 Define Center
$iPos = 0; #int($iCnt/ 2); #$iCnt
$aWk = $aThis;
$aPrev = (sizeof($aThis) > 2) ? array_splice($aWk, 1, 1) : array(); #$iPos);
$aNext = array_splice($aWk, 1); #, $iCnt - $iPos -1);
$aThis[$iPos]->PrevPps = $this->_savePpsSetPnt2($aPrev, $raList, $rhInfo);
array_push($raList, $aThis[$iPos]);
$aThis[$iPos]->No = sizeof($raList)-1;
#1.3.2 Devide a array into Previous,Next
$aThis[$iPos]->NextPps = $this->_savePpsSetPnt2($aNext, $raList, $rhInfo);
$aThis[$iPos]->DirPps = $this->_savePpsSetPnt2($aThis[$iPos]->Child, $raList, $rhInfo);
return $aThis[$iPos]->No;
}
}
#------------------------------------------------------------------------------
# _savePpsSetPnt2 (OLE::Storage_Lite::PPS::Root)
# For Test
#------------------------------------------------------------------------------
function _savePpsSetPnt2s(&$aThis, &$raList, $rhInfo) {
#1. make Array as Children-Relations
#1.1 if No Children
if (!is_array($aThis) || sizeof($aThis)==0) {
return 0xFFFFFFFF;
} elseif (sizeof($aThis)==1) {
#1.2 Just Only one
array_push($raList, $aThis[0]);
$aThis[0]->No = sizeof($raList)-1;
$aThis[0]->PrevPps = 0xFFFFFFFF;
$aThis[0]->NextPps = 0xFFFFFFFF;
$aThis[0]->DirPps = $this->_savePpsSetPnt2($aThis[0]->Child, $raList, $rhInfo);
return $aThis[0]->No;
} else {
#1.3 Array
$iCnt = sizeof($aThis);
#1.3.1 Define Center
$iPos = 0; #int($iCnt/ 2); #$iCnt
array_push($raList, $aThis[$iPos]);
$aThis[$iPos]->No = sizeof($raList)-1;
$aWk = $aThis;
#1.3.2 Devide a array into Previous,Next
$aPrev = array_splice($aWk, 0, $iPos);
$aNext = array_splice($aWk, 1, $iCnt - $iPos - 1);
$aThis[$iPos]->PrevPps = $this->_savePpsSetPnt2($aPrev, $raList, $rhInfo);
$aThis[$iPos]->NextPps = $this->_savePpsSetPnt2($aNext, $raList, $rhInfo);
$aThis[$iPos]->DirPps = $this->_savePpsSetPnt2($aThis[$iPos]->Child, $raList, $rhInfo);
return $aThis[$iPos]->No;
}
}
#------------------------------------------------------------------------------
# _savePpsSetPnt (OLE::Storage_Lite::PPS::Root)
#------------------------------------------------------------------------------
function _savePpsSetPnt(&$aThis, &$raList, $rhInfo) {
//print "yyy type: ".gettype($aThis)."<br>\n";
//print "yyy name: ".$aThis[0]->Name."<br>\n";
#1. make Array as Children-Relations
#1.1 if No Children
if (!is_array($aThis) || sizeof($aThis)==0) {
return 0xFFFFFFFF;
} elseif (sizeof($aThis)==1) {
#1.2 Just Only one
array_push($raList, $aThis[0]);
$aThis[0]->No = sizeof($raList)-1;
$aThis[0]->PrevPps = 0xFFFFFFFF;
$aThis[0]->NextPps = 0xFFFFFFFF;
$aThis[0]->DirPps = $this->_savePpsSetPnt($aThis[0]->Child, $raList, $rhInfo);
return $aThis[0]->No;
} else {
#1.3 Array
$iCnt = sizeof($aThis);
#1.3.1 Define Center
$iPos = floor($iCnt/2); #$iCnt
array_push($raList, $aThis[$iPos]);
$aThis[$iPos]->No = sizeof($raList)-1;
$aWk = $aThis;
#1.3.2 Devide a array into Previous,Next
$aPrev = splice($aWk, 0, $iPos);
$aNext = splice($aWk, 1, $iCnt - $iPos - 1);
$aThis[$iPos]->PrevPps = $this->_savePpsSetPnt($aPrev, $raList, $rhInfo);
$aThis[$iPos]->NextPps = $this->_savePpsSetPnt($aNext, $raList, $rhInfo);
$aThis[$iPos]->DirPps = $this->_savePpsSetPnt($aThis[$iPos]->Child, $raList, $rhInfo);
return $aThis[$iPos]->No;
}
}
#------------------------------------------------------------------------------
# _savePpsSetPnt (OLE::Storage_Lite::PPS::Root)
#------------------------------------------------------------------------------
function _savePpsSetPnt1(&$aThis, &$raList, $rhInfo) {
#1. make Array as Children-Relations
#1.1 if No Children
if (!is_array($aThis) || sizeof($aThis)==0) {
return 0xFFFFFFFF;
} elseif (sizeof($aThis)==1) {
#1.2 Just Only one
array_push($raList, $aThis[0]);
$aThis[0]->No = sizeof($raList)-1;
$aThis[0]->PrevPps = 0xFFFFFFFF;
$aThis[0]->NextPps = 0xFFFFFFFF;
$aThis[0]->DirPps = $this->_savePpsSetPnt($aThis[0]->Child, $raList, $rhInfo);
return $aThis[0]->No;
} else {
#1.3 Array
$iCnt = sizeof($aThis);
#1.3.1 Define Center
$iPos = floor($iCnt / 2); #$iCnt
array_push($raList, $aThis[$iPos]);
$aThis[$iPos]->No = sizeof($raList)-1;
$aWk = $aThis;
#1.3.2 Devide a array into Previous,Next
$aPrev = splice($aWk, 0, $iPos);
$aNext = splice($aWk, 1, $iCnt - $iPos - 1);
$aThis[$iPos]->PrevPps = $this->_savePpsSetPnt($aPrev, $raList, $rhInfo);
$aThis[$iPos]->NextPps = $this->_savePpsSetPnt($aNext, $raList, $rhInfo);
$aThis[$iPos]->DirPps = $this->_savePpsSetPnt($aThis[$iPos]->Child, $raList, $rhInfo);
return $aThis[$iPos]->No;
}
}
#------------------------------------------------------------------------------
# _saveBbd (OLE::Storage_Lite)
#------------------------------------------------------------------------------
function _saveBbd($iSbdSize, $iBsize, $iPpsCnt, $rhInfo) {
$FILE = $rhInfo->_FILEH_;
#0. Calculate Basic Setting
$iBbCnt = $rhInfo->_BIG_BLOCK_SIZE / LongIntSize;
$i1stBdL = ($rhInfo->_BIG_BLOCK_SIZE - 0x4C) / LongIntSize;
$iBdExL = 0;
$iAll = $iBsize + $iPpsCnt + $iSbdSize;
$iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt) ? 1 : 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
//my $i;
#0.1 Calculate BD count
if ($iBdCnt >$i1stBdL) {
// TODO: do-while correct here?
do {
$iBdExL++;
$iAllW++;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt) ? 1 : 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt) ? 1 : 0);
} while ($iBdCnt > ($iBdExL*$iBbCnt+$i1stBdL));
}
#1. Making BD
#1.1 Set for SBD
if($iSbdSize > 0) {
for ($i = 0; $i<($iSbdSize-1); $i++) {
fputs($FILE, pack("V", $i+1));
}
fputs($FILE, pack("V", -2));
}
#1.2 Set for B
for ($i = 0; $i<($iBsize-1); $i++) {
fputs($FILE, pack("V", $i+$iSbdSize+1));
}
fputs($FILE, pack("V", -2));
#1.3 Set for PPS
for ($i = 0; $i<($iPpsCnt-1); $i++) {
fputs($FILE, pack("V", $i+$iSbdSize+$iBsize+1));
}
fputs($FILE, pack("V", -2));
#1.4 Set for BBD itself ( 0xFFFFFFFD : BBD)
for ($i=0; $i<$iBdCnt;$i++) {
fputs($FILE, pack("V", 0xFFFFFFFD));
}
#1.5 Set for ExtraBDList
for ($i=0; $i<$iBdExL;$i++) {
fputs($FILE, pack("V", 0xFFFFFFFC));
}
#1.6 Adjust for Block
if(($iAllW + $iBdCnt) % $iBbCnt) {
fputs($FILE, str_repeat(pack("V", -1), ($iBbCnt - (($iAllW + $iBdCnt) % $iBbCnt))));
}
#2.Extra BDList
if($iBdCnt > $i1stBdL) {
$iN=0;
$iNb=0;
for ($i=$i1stBdL;$i<$iBdCnt; $i++, $iN++) {
if($iN>=($iBbCnt-1)) {
$iN = 0;
$iNb++;
fputs($FILE, pack("V", $iAll+$iBdCnt+$iNb));
}
fputs($FILE, pack("V", $iBsize+$iSbdSize+$iPpsCnt+$i));
}
if(($iBdCnt-$i1stBdL) % ($iBbCnt-1)) {
fputs($FILE, str_repeat(pack("V", -1), (($iBbCnt-1) - (($iBdCnt-$i1stBdL) % ($iBbCnt-1)))));
}
fputs($FILE, pack("V", -2));
}
}
}
?>

View File

@@ -1,209 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
class writeexcel_biffwriter {
var $byte_order;
var $BIFF_version;
var $_byte_order;
var $_data;
var $_datasize;
var $_limit;
var $_debug;
/*
* Constructor
*/
function writeexcel_biffwriter() {
$this->byte_order = '';
$this->BIFF_version = 0x0500;
$this->_byte_order = '';
$this->_data = false;
$this->_datasize = 0;
$this->_limit = 2080;
$this->_set_byte_order();
}
/*
* Determine the byte order and store it as class data to avoid
* recalculating it for each call to new().
*/
function _set_byte_order() {
$this->byteorder=0;
// Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345);
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
$this->byte_order = 0; // Little Endian
} elseif ($number == strrev($teststr)) {
$this->byte_order = 1; // Big Endian
} else {
// Give up
trigger_error("Required floating point format not supported ".
"on this platform. See the portability section ".
"of the documentation.", E_USER_ERROR);
}
$this->_byte_order = $this->byte_order;
}
/*
* General storage function
*/
function _prepend($data) {
if (func_num_args()>1) {
trigger_error("writeexcel_biffwriter::_prepend() ".
"called with more than one argument", E_USER_ERROR);
}
if ($this->_debug) {
print "*** writeexcel_biffwriter::_prepend() called:";
for ($c=0;$c<strlen($data);$c++) {
if ($c%16==0) {
print "\n";
}
printf("%02X ", ord($data[$c]));
}
print "\n";
}
if (strlen($data) > $this->_limit) {
$data = $this->_add_continue($data);
}
$this->_data = $data . $this->_data;
$this->_datasize += strlen($data);
}
/*
* General storage function
*/
function _append($data) {
if (func_num_args()>1) {
trigger_error("writeexcel_biffwriter::_append() ".
"called with more than one argument", E_USER_ERROR);
}
if ($this->_debug) {
print "*** writeexcel_biffwriter::_append() called:";
for ($c=0;$c<strlen($data);$c++) {
if ($c%16==0) {
print "\n";
}
printf("%02X ", ord($data[$c]));
}
print "\n";
}
if (strlen($data) > $this->_limit) {
$data = $this->_add_continue($data);
}
$this->_data = $this->_data . $data;
$this->_datasize += strlen($data);
}
/*
* Writes Excel BOF record to indicate the beginning of a stream or
* sub-stream in the BIFF file.
*
* $type = 0x0005, Workbook
* $type = 0x0010, Worksheet
*/
function _store_bof($type) {
$record = 0x0809; // Record identifier
$length = 0x0008; // Number of bytes to follow
$version = $this->BIFF_version;
// According to the SDK $build and $year should be set to zero.
// However, this throws a warning in Excel 5. So, use these
// magic numbers.
$build = 0x096C;
$year = 0x07C9;
$header = pack("vv", $record, $length);
$data = pack("vvvv", $version, $type, $build, $year);
$this->_prepend($header . $data);
}
/*
* Writes Excel EOF record to indicate the end of a BIFF stream.
*/
function _store_eof() {
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header);
}
/*
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084
* bytes. In Excel 97 the limit is 8228 bytes. Records that are longer
* than these limits must be split up into CONTINUE blocks.
*
* This function take a long BIFF record and inserts CONTINUE records as
* necessary.
*/
function _add_continue($data) {
$limit = $this->_limit;
$record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record.
$tmp = substr($data, 0, $limit);
$data = substr($data, $limit);
$tmp = substr($tmp, 0, 2) . pack ("v", $limit-4) . substr($tmp, 4);
// Strip out chunks of 2080/8224 bytes +4 for the header.
while (strlen($data) > $limit) {
$header = pack("vv", $record, $limit);
$tmp .= $header;
$tmp .= substr($data, 0, $limit);
$data = substr($data, $limit);
}
// Mop up the last of the data
$header = pack("vv", $record, strlen($data));
$tmp .= $header;
$tmp .= $data;
return $tmp;
}
}
?>

View File

@@ -1,695 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
class writeexcel_format {
var $_xf_index;
var $_font_index;
var $_font;
var $_size;
var $_bold;
var $_italic;
var $_color;
var $_underline;
var $_font_strikeout;
var $_font_outline;
var $_font_shadow;
var $_font_script;
var $_font_family;
var $_font_charset;
var $_num_format;
var $_hidden;
var $_locked;
var $_text_h_align;
var $_text_wrap;
var $_text_v_align;
var $_text_justlast;
var $_rotation;
var $_fg_color;
var $_bg_color;
var $_pattern;
var $_bottom;
var $_top;
var $_left;
var $_right;
var $_bottom_color;
var $_top_color;
var $_left_color;
var $_right_color;
/*
* Constructor
*/
function writeexcel_format() {
$_=func_get_args();
$this->_xf_index = (sizeof($_)>0) ? array_shift($_) : 0;
$this->_font_index = 0;
$this->_font = 'Arial';
$this->_size = 10;
$this->_bold = 0x0190;
$this->_italic = 0;
$this->_color = 0x7FFF;
$this->_underline = 0;
$this->_font_strikeout = 0;
$this->_font_outline = 0;
$this->_font_shadow = 0;
$this->_font_script = 0;
$this->_font_family = 0;
$this->_font_charset = 0;
$this->_num_format = 0;
$this->_hidden = 0;
$this->_locked = 1;
$this->_text_h_align = 0;
$this->_text_wrap = 0;
$this->_text_v_align = 2;
$this->_text_justlast = 0;
$this->_rotation = 0;
$this->_fg_color = 0x40;
$this->_bg_color = 0x41;
$this->_pattern = 0;
$this->_bottom = 0;
$this->_top = 0;
$this->_left = 0;
$this->_right = 0;
$this->_bottom_color = 0x40;
$this->_top_color = 0x40;
$this->_left_color = 0x40;
$this->_right_color = 0x40;
// Set properties passed to writeexcel_workbook::addformat()
if (sizeof($_)>0) {
call_user_func_array(array(&$this, 'set_properties'), $_);
}
}
/*
* Copy the attributes of another writeexcel_format object.
*/
function copy($other) {
$xf = $this->_xf_index; // Backup XF index
foreach ($other as $key->$value) {
$this->{$key} = $value;
}
$this->_xf_index = $xf; // Restore XF index
}
/*
* Generate an Excel BIFF XF record.
*/
function get_xf() {
$_=func_get_args();
// $record Record identifier
// $length Number of bytes to follow
// $ifnt Index to FONT record
// $ifmt Index to FORMAT record
// $style Style and other options
// $align Alignment
// $icv fg and bg pattern colors
// $fill Fill and border line style
// $border1 Border line style and color
// $border2 Border color
// Set the type of the XF record and some of the attributes.
if ($_[0] == "style") {
$style = 0xFFF5;
} else {
$style = $this->_locked;
$style |= $this->_hidden << 1;
}
// Flags to indicate if attributes have been set.
$atr_num = ($this->_num_format != 0) ? 1 : 0;
$atr_fnt = ($this->_font_index != 0) ? 1 : 0;
$atr_alc = $this->_text_wrap ? 1 : 0;
$atr_bdr = ($this->_bottom ||
$this->_top ||
$this->_left ||
$this->_right) ? 1 : 0;
$atr_pat = ($this->_fg_color != 0x41 ||
$this->_bg_color != 0x41 ||
$this->_pattern != 0x00) ? 1 : 0;
$atr_prot = 0;
// Reset the default colors for the non-font properties
if ($this->_fg_color == 0x7FFF) $this->_fg_color = 0x40;
if ($this->_bg_color == 0x7FFF) $this->_bg_color = 0x41;
if ($this->_bottom_color == 0x7FFF) $this->_bottom_color = 0x41;
if ($this->_top_color == 0x7FFF) $this->_top_color = 0x41;
if ($this->_left_color == 0x7FFF) $this->_left_color = 0x41;
if ($this->_right_color == 0x7FFF) $this->_right_color = 0x41;
// Zero the default border colour if the border has not been set.
if ($this->_bottom == 0) {
$this->_bottom_color = 0;
}
if ($this->_top == 0) {
$this->_top_color = 0;
}
if ($this->_right == 0) {
$this->_right_color = 0;
}
if ($this->_left == 0) {
$this->_left_color = 0;
}
// The following 2 logical statements take care of special cases in
// relation to cell colors and patterns:
// 1. For a solid fill (_pattern == 1) Excel reverses the role of
// foreground and background colors
// 2. If the user specifies a foreground or background color
// without a pattern they probably wanted a solid fill, so we
// fill in the defaults.
if ($this->_pattern <= 0x01 &&
$this->_bg_color != 0x41 &&
$this->_fg_color == 0x40 )
{
$this->_fg_color = $this->_bg_color;
$this->_bg_color = 0x40;
$this->_pattern = 1;
}
if ($this->_pattern <= 0x01 &&
$this->_bg_color == 0x41 &&
$this->_fg_color != 0x40 )
{
$this->_bg_color = 0x40;
$this->_pattern = 1;
}
$record = 0x00E0;
$length = 0x0010;
$ifnt = $this->_font_index;
$ifmt = $this->_num_format;
$align = $this->_text_h_align;
$align |= $this->_text_wrap << 3;
$align |= $this->_text_v_align << 4;
$align |= $this->_text_justlast << 7;
$align |= $this->_rotation << 8;
$align |= $atr_num << 10;
$align |= $atr_fnt << 11;
$align |= $atr_alc << 12;
$align |= $atr_bdr << 13;
$align |= $atr_pat << 14;
$align |= $atr_prot << 15;
$icv = $this->_fg_color;
$icv |= $this->_bg_color << 7;
$fill = $this->_pattern;
$fill |= $this->_bottom << 6;
$fill |= $this->_bottom_color << 9;
$border1 = $this->_top;
$border1 |= $this->_left << 3;
$border1 |= $this->_right << 6;
$border1 |= $this->_top_color << 9;
$border2 = $this->_left_color;
$border2 |= $this->_right_color << 7;
$header = pack("vv", $record, $length);
$data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
$icv, $fill,
$border1, $border2);
return($header . $data);
}
/*
* Generate an Excel BIFF FONT record.
*/
function get_font() {
// $record Record identifier
// $length Record length
// $dyHeight Height of font (1/20 of a point)
// $grbit Font attributes
// $icv Index to color palette
// $bls Bold style
// $sss Superscript/subscript
// $uls Underline
// $bFamily Font family
// $bCharSet Character set
// $reserved Reserved
// $cch Length of font name
// $rgch Font name
$dyHeight = $this->_size * 20;
$icv = $this->_color;
$bls = $this->_bold;
$sss = $this->_font_script;
$uls = $this->_underline;
$bFamily = $this->_font_family;
$bCharSet = $this->_font_charset;
$rgch = $this->_font;
$cch = strlen($rgch);
$record = 0x31;
$length = 0x0F + $cch;
$reserved = 0x00;
$grbit = 0x00;
if ($this->_italic) {
$grbit |= 0x02;
}
if ($this->_font_strikeout) {
$grbit |= 0x08;
}
if ($this->_font_outline) {
$grbit |= 0x10;
}
if ($this->_font_shadow) {
$grbit |= 0x20;
}
$header = pack("vv", $record, $length);
$data = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
$sss, $uls, $bFamily,
$bCharSet, $reserved, $cch);
return($header . $data . $this->_font);
}
/*
* Returns a unique hash key for a font.
* Used by writeexcel_workbook::_store_all_fonts()
*/
function get_font_key() {
# The following elements are arranged to increase the probability of
# generating a unique key. Elements that hold a large range of numbers
# eg. _color are placed between two binary elements such as _italic
#
$key = $this->_font.$this->_size.
$this->_font_script.$this->_underline.
$this->_font_strikeout.$this->_bold.$this->_font_outline.
$this->_font_family.$this->_font_charset.
$this->_font_shadow.$this->_color.$this->_italic;
$key = preg_replace('/ /', '_', $key); # Convert the key to a single word
return $key;
}
/*
* Returns the used by Worksheet->_XF()
*/
function get_xf_index() {
return $this->_xf_index;
}
/*
* Used in conjunction with the set_xxx_color methods to convert a color
* string into a number. Color range is 0..63 but we will restrict it
* to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15.
*/
function _get_color($color=false) {
$colors = array(
'aqua' => 0x0F,
'cyan' => 0x0F,
'black' => 0x08,
'blue' => 0x0C,
'brown' => 0x10,
'magenta' => 0x0E,
'fuchsia' => 0x0E,
'gray' => 0x17,
'grey' => 0x17,
'green' => 0x11,
'lime' => 0x0B,
'navy' => 0x12,
'orange' => 0x35,
'purple' => 0x14,
'red' => 0x0A,
'silver' => 0x16,
'white' => 0x09,
'yellow' => 0x0D
);
// Return the default color, 0x7FFF, if undef,
if ($color===false) {
return 0x7FFF;
}
// or the color string converted to an integer,
if (isset($colors[strtolower($color)])) {
return $colors[strtolower($color)];
}
// or the default color if string is unrecognised,
if (preg_match('/\D/', $color)) {
return 0x7FFF;
}
// or an index < 8 mapped into the correct range,
if ($color<8) {
return $color + 8;
}
// or the default color if arg is outside range,
if ($color>63) {
return 0x7FFF;
}
// or an integer in the valid range
return $color;
}
/*
* Set cell alignment.
*/
function set_align($location) {
// Ignore numbers
if (preg_match('/\d/', $location)) {
return;
}
$location = strtolower($location);
switch ($location) {
case 'left':
$this->set_text_h_align(1);
break;
case 'centre':
case 'center':
$this->set_text_h_align(2);
break;
case 'right':
$this->set_text_h_align(3);
break;
case 'fill':
$this->set_text_h_align(4);
break;
case 'justify':
$this->set_text_h_align(5);
break;
case 'merge':
$this->set_text_h_align(6);
break;
case 'equal_space':
$this->set_text_h_align(7);
break;
case 'top':
$this->set_text_v_align(0);
break;
case 'vcentre':
case 'vcenter':
$this->set_text_v_align(1);
break;
break;
case 'bottom':
$this->set_text_v_align(2);
break;
case 'vjustify':
$this->set_text_v_align(3);
break;
case 'vequal_space':
$this->set_text_v_align(4);
break;
}
}
/*
* Set vertical cell alignment. This is required by the set_properties()
* method to differentiate between the vertical and horizontal properties.
*/
function set_valign($location) {
$this->set_align($location);
}
/*
* This is an alias for the unintuitive set_align('merge')
*/
function set_merge() {
$this->set_text_h_align(6);
}
/*
* Bold has a range 0x64..0x3E8.
* 0x190 is normal. 0x2BC is bold.
*/
function set_bold($weight=1) {
if ($weight == 1) {
// Bold text
$weight = 0x2BC;
}
if ($weight == 0) {
// Normal text
$weight = 0x190;
}
if ($weight < 0x064) {
// Lower bound
$weight = 0x190;
}
if ($weight > 0x3E8) {
// Upper bound
$weight = 0x190;
}
$this->_bold = $weight;
}
/*
* Set all cell borders (bottom, top, left, right) to the same style
*/
function set_border($style) {
$this->set_bottom($style);
$this->set_top($style);
$this->set_left($style);
$this->set_right($style);
}
/*
* Set all cell borders (bottom, top, left, right) to the same color
*/
function set_border_color($color) {
$this->set_bottom_color($color);
$this->set_top_color($color);
$this->set_left_color($color);
$this->set_right_color($color);
}
/*
* Convert hashes of properties to method calls.
*/
function set_properties() {
$_=func_get_args();
$properties=array();
foreach($_ as $props) {
if (is_array($props)) {
$properties=array_merge($properties, $props);
} else {
$properties[]=$props;
}
}
foreach ($properties as $key=>$value) {
// Strip leading "-" from Tk style properties eg. -color => 'red'.
$key = preg_replace('/^-/', '', $key);
/* Make sure method names are alphanumeric characters only, in
case tainted data is passed to the eval(). */
if (preg_match('/\W/', $key)) {
trigger_error("Unknown property: $key.",
E_USER_ERROR);
}
/* Evaling all $values as a strings gets around the problem of
some numerical format strings being evaluated as numbers, for
example "00000" for a zip code. */
if (is_int($key)) {
eval("\$this->set_$value();");
} else {
eval("\$this->set_$key('$value');");
}
}
}
function set_font($font) {
$this->_font=$font;
}
function set_size($size) {
$this->_size=$size;
}
function set_italic($italic=1) {
$this->_italic=$italic;
}
function set_color($color) {
$this->_color=$this->_get_color($color);
}
function set_underline($underline=1) {
$this->_underline=$underline;
}
function set_font_strikeout($font_strikeout=1) {
$this->_font_strikeout=$font_strikeout;
}
function set_font_outline($font_outline=1) {
$this->_font_outline=$font_outline;
}
function set_font_shadow($font_shadow=1) {
$this->_font_shadow=$font_shadow;
}
function set_font_script($font_script=1) {
$this->_font_script=$font_script;
}
/* Undocumented */
function set_font_family($font_family=1) {
$this->_font_family=$font_family;
}
/* Undocumented */
function set_font_charset($font_charset=1) {
$this->_font_charset=$font_charset;
}
function set_num_format($num_format=1) {
$this->_num_format=$num_format;
}
function set_hidden($hidden=1) {
$this->_hidden=$hidden;
}
function set_locked($locked=1) {
$this->_locked=$locked;
}
function set_text_h_align($align) {
$this->_text_h_align=$align;
}
function set_text_wrap($wrap=1) {
$this->_text_wrap=$wrap;
}
function set_text_v_align($align) {
$this->_text_v_align=$align;
}
function set_text_justlast($text_justlast=1) {
$this->_text_justlast=$text_justlast;
}
function set_rotation($rotation=1) {
$this->_rotation=$rotation;
}
function set_fg_color($color) {
$this->_fg_color=$this->_get_color($color);
}
function set_bg_color($color) {
$this->_bg_color=$this->_get_color($color);
}
function set_pattern($pattern=1) {
$this->_pattern=$pattern;
}
function set_bottom($bottom=1) {
$this->_bottom=$bottom;
}
function set_top($top=1) {
$this->_top=$top;
}
function set_left($left=1) {
$this->_left=$left;
}
function set_right($right=1) {
$this->_right=$right;
}
function set_bottom_color($color) {
$this->_bottom_color=$this->_get_color($color);
}
function set_top_color($color) {
$this->_top_color=$this->_get_color($color);
}
function set_left_color($color) {
$this->_left_color=$this->_get_color($color);
}
function set_right_color($color) {
$this->_right_color=$this->_get_color($color);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,353 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
class writeexcel_olewriter {
var $_OLEfilename;
var $_OLEtmpfilename; /* ABR */
var $_filehandle;
var $_fileclosed;
var $_internal_fh;
var $_biff_only;
var $_size_allowed;
var $_biffsize;
var $_booksize;
var $_big_blocks;
var $_list_blocks;
var $_root_start;
var $_block_count;
/*
* Constructor
*/
function writeexcel_olewriter($filename) {
$this->_OLEfilename = $filename;
$this->_filehandle = false;
$this->_fileclosed = 0;
$this->_internal_fh = 0;
$this->_biff_only = 0;
$this->_size_allowed = 0;
$this->_biffsize = 0;
$this->_booksize = 0;
$this->_big_blocks = 0;
$this->_list_blocks = 0;
$this->_root_start = 0;
$this->_block_count = 4;
$this->_initialize();
}
/*
* Check for a valid filename and store the filehandle.
*/
function _initialize() {
$OLEfile = $this->_OLEfilename;
/* Check for a filename. Workbook.pm will catch this first. */
if ($OLEfile == '') {
trigger_error("Filename required", E_USER_ERROR);
}
/*
* If the filename is a resource it is assumed that it is a valid
* filehandle, if not we create a filehandle.
*/
if (is_resource($OLEfile)) {
$fh = $OLEfile;
} else {
// Create a new file, open for writing
$fh = fopen($OLEfile, "wb");
// The workbook class also checks this but something may have
// happened since then.
if (!$fh) {
trigger_error("Can't open $OLEfile. It may be in use or ".
"protected", E_USER_ERROR);
}
$this->_internal_fh = 1;
}
// Store filehandle
$this->_filehandle = $fh;
}
/*
* Set the size of the data to be written to the OLE stream
*
* $big_blocks = (109 depot block x (128 -1 marker word)
* - (1 x end words)) = 13842
* $maxsize = $big_blocks * 512 bytes = 7087104
*/
function set_size($size) {
$maxsize = 7087104;
if ($size > $maxsize) {
trigger_error("Maximum file size, $maxsize, exceeded. To create ".
"files bigger than this limit please use the ".
"workbookbig class.", E_USER_ERROR);
return ($this->_size_allowed = 0);
}
$this->_biffsize = $size;
// Set the min file size to 4k to avoid having to use small blocks
if ($size > 4096) {
$this->_booksize = $size;
} else {
$this->_booksize = 4096;
}
return ($this->_size_allowed = 1);
}
/*
* Calculate various sizes needed for the OLE stream
*/
function _calculate_sizes() {
$datasize = $this->_booksize;
if ($datasize % 512 == 0) {
$this->_big_blocks = $datasize/512;
} else {
$this->_big_blocks = floor($datasize/512)+1;
}
// There are 127 list blocks and 1 marker blocks for each big block
// depot + 1 end of chain block
$this->_list_blocks = floor(($this->_big_blocks)/127)+1;
$this->_root_start = $this->_big_blocks;
//print $this->_biffsize. "\n";
//print $this->_big_blocks. "\n";
//print $this->_list_blocks. "\n";
}
/*
* Write root entry, big block list and close the filehandle.
* This method must be called so that the file contents are
* actually written.
*/
function close() {
if (!$this->_size_allowed) {
return;
}
if (!$this->_biff_only) {
$this->_write_padding();
$this->_write_property_storage();
$this->_write_big_block_depot();
}
// Close the filehandle if it was created internally.
if ($this->_internal_fh) {
fclose($this->_filehandle);
}
/* ABR */
if ($this->_OLEtmpfilename != '') {
$fh = fopen($this->_OLEtmpfilename, "rb");
if ($fh == false) {
trigger_error("Can't read temporary file.", E_USER_ERROR);
}
fpassthru($fh);
fclose($fh);
unlink($this->_OLEtmpfilename);
};
$this->_fileclosed = 1;
}
/*
* Write BIFF data to OLE file.
*/
function write($data) {
fputs($this->_filehandle, $data);
}
/*
* Write OLE header block.
*/
function write_header() {
if ($this->_biff_only) {
return;
}
$this->_calculate_sizes();
$root_start = $this->_root_start;
$num_lists = $this->_list_blocks;
$id = pack("C8", 0xD0, 0xCF, 0x11, 0xE0,
0xA1, 0xB1, 0x1A, 0xE1);
$unknown1 = pack("VVVV", 0x00, 0x00, 0x00, 0x00);
$unknown2 = pack("vv", 0x3E, 0x03);
$unknown3 = pack("v", -2);
$unknown4 = pack("v", 0x09);
$unknown5 = pack("VVV", 0x06, 0x00, 0x00);
$num_bbd_blocks = pack("V", $num_lists);
$root_startblock = pack("V", $root_start);
$unknown6 = pack("VV", 0x00, 0x1000);
$sbd_startblock = pack("V", -2);
$unknown7 = pack("VVV", 0x00, -2 ,0x00);
$unused = pack("V", -1);
fputs($this->_filehandle, $id);
fputs($this->_filehandle, $unknown1);
fputs($this->_filehandle, $unknown2);
fputs($this->_filehandle, $unknown3);
fputs($this->_filehandle, $unknown4);
fputs($this->_filehandle, $unknown5);
fputs($this->_filehandle, $num_bbd_blocks);
fputs($this->_filehandle, $root_startblock);
fputs($this->_filehandle, $unknown6);
fputs($this->_filehandle, $sbd_startblock);
fputs($this->_filehandle, $unknown7);
for ($c=1;$c<=$num_lists;$c++) {
$root_start++;
fputs($this->_filehandle, pack("V", $root_start));
}
for ($c=$num_lists;$c<=108;$c++) {
fputs($this->_filehandle, $unused);
}
}
/*
* Write big block depot.
*/
function _write_big_block_depot() {
$num_blocks = $this->_big_blocks;
$num_lists = $this->_list_blocks;
$total_blocks = $num_lists * 128;
$used_blocks = $num_blocks + $num_lists + 2;
$marker = pack("V", -3);
$end_of_chain = pack("V", -2);
$unused = pack("V", -1);
for ($i=1;$i<=($num_blocks-1);$i++) {
fputs($this->_filehandle, pack("V", $i));
}
fputs($this->_filehandle, $end_of_chain);
fputs($this->_filehandle, $end_of_chain);
for ($c=1;$c<=$num_lists;$c++) {
fputs($this->_filehandle, $marker);
}
for ($c=$used_blocks;$c<=$total_blocks;$c++) {
fputs($this->_filehandle, $unused);
}
}
/*
* Write property storage. TODO: add summary sheets
*/
function _write_property_storage() {
$rootsize = -2;
$booksize = $this->_booksize;
// name type dir start size
$this->_write_pps('Root Entry', 0x05, 1, -2, 0x00);
$this->_write_pps('Book', 0x02, -1, 0x00, $booksize);
$this->_write_pps('', 0x00, -1, 0x00, 0x0000);
$this->_write_pps('', 0x00, -1, 0x00, 0x0000);
}
/*
* Write property sheet in property storage
*/
function _write_pps($name, $type, $dir, $start, $size) {
$names = array();
$length = 0;
if ($name != '') {
$name = $name . "\0";
// Simulate a Unicode string
$chars=preg_split("''", $name, -1, PREG_SPLIT_NO_EMPTY);
foreach ($chars as $char) {
array_push($names, ord($char));
}
$length = strlen($name) * 2;
}
$rawname = call_user_func_array('pack', array_merge(array("v*"), $names));
$zero = pack("C", 0);
$pps_sizeofname = pack("v", $length); //0x40
$pps_type = pack("v", $type); //0x42
$pps_prev = pack("V", -1); //0x44
$pps_next = pack("V", -1); //0x48
$pps_dir = pack("V", $dir); //0x4c
$unknown1 = pack("V", 0);
$pps_ts1s = pack("V", 0); //0x64
$pps_ts1d = pack("V", 0); //0x68
$pps_ts2s = pack("V", 0); //0x6c
$pps_ts2d = pack("V", 0); //0x70
$pps_sb = pack("V", $start); //0x74
$pps_size = pack("V", $size); //0x78
fputs($this->_filehandle, $rawname);
fputs($this->_filehandle, str_repeat($zero, (64-$length)));
fputs($this->_filehandle, $pps_sizeofname);
fputs($this->_filehandle, $pps_type);
fputs($this->_filehandle, $pps_prev);
fputs($this->_filehandle, $pps_next);
fputs($this->_filehandle, $pps_dir);
fputs($this->_filehandle, str_repeat($unknown1, 5));
fputs($this->_filehandle, $pps_ts1s);
fputs($this->_filehandle, $pps_ts1d);
fputs($this->_filehandle, $pps_ts2d);
fputs($this->_filehandle, $pps_ts2d);
fputs($this->_filehandle, $pps_sb);
fputs($this->_filehandle, $pps_size);
fputs($this->_filehandle, $unknown1);
}
/*
* Pad the end of the file
*/
function _write_padding() {
$biffsize = $this->_biffsize;
if ($biffsize < 4096) {
$min_size = 4096;
} else {
$min_size = 512;
}
if ($biffsize % $min_size != 0) {
$padding = $min_size - ($biffsize % $min_size);
fputs($this->_filehandle, str_repeat("\0", $padding));
}
}
}
?>

View File

@@ -1,55 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
require_once "class.writeexcel_workbook.inc.php";
require_once "class.ole_pps_root.php";
require_once "class.ole_pps_file.php";
class writeexcel_workbookbig extends writeexcel_workbook {
function writeexcel_workbookbig($filename) {
$this->writeexcel_workbook($filename);
}
function _store_OLE_file() {
$file=new ole_pps_file(asc2ucs("Book"));
$file->append($this->_data);
for ($c=0;$c<sizeof($this->_worksheets);$c++) {
$worksheet=&$this->_worksheets[$c];
while ($data=$worksheet->get_data()) {
$file->append($data);
}
$worksheet->cleanup();
}
$ole=new ole_pps_root(false, false, array($file));
$ole->save($this->_filename);
}
}
?>

View File

@@ -1,28 +0,0 @@
<?php
set_time_limit(300);
require_once "class.writeexcel_workbookbig.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "bigfile.xls");
$workbook = &new writeexcel_workbookbig($fname);
$worksheet = &$workbook->addworksheet();
$worksheet->set_column(0, 50, 18);
for ($col=0;$col<50;$col++) {
for ($row=0;$row<6000;$row++) {
$worksheet->write($row, $col, "ROW:$row COL:$col");
}
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-bigfile.xls\"");
header("Content-Disposition: inline; filename=\"example-bigfile.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,122 +0,0 @@
<?php
# Demonstrates Spreadsheet::WriteExcel's named colors and the Excel
# color palette.
#
# reverse('<27>'), March 2002, John McNamara, jmcnamara@cpan.org
# PHP port by Johann Hanne, 2005-11-01
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "colors.xls");
$workbook = new writeexcel_workbook($fname);
# Some common formats
$center =& $workbook->addformat(array('align' => 'center'));
$heading =& $workbook->addformat(array('align' => 'center', 'bold' => 1));
# Try this to see the default Excel 5 palette
# $workbook->set_palette_xl5();
######################################################################
#
# Demonstrate the named colors.
#
$colors = array(
'black'=>0x08,
'blue'=>0x0C,
'brown'=>0x10,
'cyan'=>0x0F,
'gray'=>0x17,
'green'=>0x11,
'lime'=>0x0B,
'magenta'=>0x0E,
'navy'=>0x12,
'orange'=>0x35,
'purple'=>0x14,
'red'=>0x0A,
'silver'=>0x16,
'white'=>0x09,
'yellow'=>0x0D
);
$worksheet1 =& $workbook->addworksheet('Named colors');
$worksheet1->set_column(0, 3, 15);
$worksheet1->write(0, 0, "Index", $heading);
$worksheet1->write(0, 1, "Index", $heading);
$worksheet1->write(0, 2, "Name", $heading);
$worksheet1->write(0, 3, "Color", $heading);
$i = 1;
foreach ($colors as $color=>$index) {
$format =& $workbook->addformat(array(
'fg_color' => $color,
'pattern' => 1,
'border' => 1
));
$worksheet1->write($i+1, 0, $index, $center);
$worksheet1->write($i+1, 1, sprintf("0x%02X", $index), $center);
$worksheet1->write($i+1, 2, $color, $center);
$worksheet1->write($i+1, 3, '', $format);
$i++;
}
######################################################################
#
# Demonstrate the standard Excel colors in the range 8..63.
#
$worksheet2 =& $workbook->addworksheet('Standard colors');
$worksheet2->set_column(0, 3, 15);
$worksheet2->write(0, 0, "Index", $heading);
$worksheet2->write(0, 1, "Index", $heading);
$worksheet2->write(0, 2, "Color", $heading);
$worksheet2->write(0, 3, "Name", $heading);
for ($i=8;$i<=63;$i++) {
$format =& $workbook->addformat(array(
'fg_color' => $i,
'pattern' => 1,
'border' => 1
));
$worksheet2->write(($i -7), 0, $i, $center);
$worksheet2->write(($i -7), 1, sprintf("0x%02X", $i), $center);
$worksheet2->write(($i -7), 2, '', $format);
# Add the color names
foreach ($colors as $color=>$index) {
if ($i==$index) {
$worksheet2->write(($i -7), 3, $color, $center);
}
}
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-colors.xls\"");
header("Content-Disposition: inline; filename=\"example-colors.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,97 +0,0 @@
<?php
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "demo.xls");
$workbook =& new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet('Demo');
$worksheet2 =& $workbook->addworksheet('Another sheet');
$worksheet3 =& $workbook->addworksheet('And another');
#######################################################################
#
# Write a general heading
#
$worksheet->set_column('A:B', 32);
$heading =& $workbook->addformat(array(
'bold' => 1,
'color' => 'blue',
'size' => 18,
'merge' => 1,
));
$headings = array('Features of php_writeexcel', '');
$worksheet->write_row('A1', $headings, $heading);
#######################################################################
#
# Some text examples
#
$text_format =& $workbook->addformat(array(
'bold' => 1,
'italic' => 1,
'color' => 'red',
'size' => 18,
'font' => 'Comic Sans MS'
));
$worksheet->write('A2', "Text");
$worksheet->write('B2', "Hello Excel");
$worksheet->write('A3', "Formatted text");
$worksheet->write('B3', "Hello Excel", $text_format);
#######################################################################
#
# Some numeric examples
#
$num1_format =& $workbook->addformat(array('num_format' => '$#,##0.00'));
$num2_format =& $workbook->addformat(array('num_format' => ' d mmmm yyy'));
$worksheet->write('A4', "Numbers");
$worksheet->write('B4', 1234.56);
$worksheet->write('A5', "Formatted numbers");
$worksheet->write('B5', 1234.56, $num1_format);
$worksheet->write('A6', "Formatted numbers");
$worksheet->write('B6', 37257, $num2_format);
#######################################################################
#
# Formulae
#
$worksheet->set_selection('B7');
$worksheet->write('A7', 'Formulas and functions, "=SIN(PI()/4)"');
$worksheet->write('B7', '=SIN(PI()/4)');
#######################################################################
#
# Hyperlinks
#
$worksheet->write('A8', "Hyperlinks");
$worksheet->write('B8', 'http://www.php.net/');
#######################################################################
#
# Images
#
$worksheet->write('A9', "Images");
$worksheet->insert_bitmap('B9', 'php.bmp', 16, 8);
#######################################################################
#
# Misc
#
$worksheet->write('A17', "Page/printer setup");
$worksheet->write('A18', "Multiple worksheets");
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-demo.xls\"");
header("Content-Disposition: inline; filename=\"example-demo.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,60 +0,0 @@
<?php
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "merge2.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();
# Set the column width for columns 2 and 3
$worksheet->set_column(1, 2, 20);
# Set the row height for row 2
$worksheet->set_row(2, 30);
# Create a border format
$border1 =& $workbook->addformat();
$border1->set_color('white');
$border1->set_bold();
$border1->set_size(15);
$border1->set_pattern(0x1);
$border1->set_fg_color('green');
$border1->set_border_color('yellow');
$border1->set_top(6);
$border1->set_bottom(6);
$border1->set_left(6);
$border1->set_align('center');
$border1->set_align('vcenter');
$border1->set_merge(); # This is the key feature
# Create another border format. Note you could use copy() here.
$border2 =& $workbook->addformat();
$border2->set_color('white');
$border2->set_bold();
$border2->set_size(15);
$border2->set_pattern(0x1);
$border2->set_fg_color('green');
$border2->set_border_color('yellow');
$border2->set_top(6);
$border2->set_bottom(6);
$border2->set_right(6);
$border2->set_align('center');
$border2->set_align('vcenter');
$border2->set_merge(); # This is the key feature
# Only one cell should contain text, the others should be blank.
$worksheet->write (2, 1, "Merged Cells", $border1);
$worksheet->write_blank(2, 2, $border2);
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-merge2.xls\"");
header("Content-Disposition: inline; filename=\"example-merge2.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,144 +0,0 @@
<?php
# Example of using the WriteExcel module to create worksheet panes.
#
# reverse('<27>'), May 2001, John McNamara, jmcnamara@cpan.org
# PHP port by Johann Hanne, 2005-11-01
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "panes.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet1 =& $workbook->addworksheet('Panes 1');
$worksheet2 =& $workbook->addworksheet('Panes 2');
$worksheet3 =& $workbook->addworksheet('Panes 3');
$worksheet4 =& $workbook->addworksheet('Panes 4');
# Frozen panes
$worksheet1->freeze_panes(1, 0); # 1 row
$worksheet2->freeze_panes(0, 1); # 1 column
$worksheet3->freeze_panes(1, 1); # 1 row and column
# Un-frozen panes. The divisions must be specified in terms of row and column
# dimensions. The default row height is 12.75 and the default column width
# is 8.43
#
$worksheet4->thaw_panes(12.75, 8.43, 1, 1); # 1 row and column
#######################################################################
#
# Set up some formatting and text to highlight the panes
#
$header =& $workbook->addformat();
$header->set_color('white');
$header->set_align('center');
$header->set_align('vcenter');
$header->set_pattern();
$header->set_fg_color('green');
$center =& $workbook->addformat();
$center->set_align('center');
#######################################################################
#
# Sheet 1
#
$worksheet1->set_column('A:I', 16);
$worksheet1->set_row(0, 20);
$worksheet1->set_selection('C3');
for ($i=0;$i<=8;$i++) {
$worksheet1->write(0, $i, 'Scroll down', $header);
}
for ($i=1;$i<=100;$i++) {
for ($j=0;$j<=8;$j++) {
$worksheet1->write($i, $j, $i+1, $center);
}
}
#######################################################################
#
# Sheet 2
#
$worksheet2->set_column('A:A', 16);
$worksheet2->set_selection('C3');
for ($i=0;$i<=49;$i++) {
$worksheet2->set_row($i, 15);
$worksheet2->write($i, 0, 'Scroll right', $header);
}
for ($i=0;$i<=49;$i++) {
for ($j=1;$j<=25;$j++) {
$worksheet2->write($i, $j, $j, $center);
}
}
#######################################################################
#
# Sheet 3
#
$worksheet3->set_column('A:Z', 16);
$worksheet3->set_selection('C3');
for ($i=1;$i<=25;$i++) {
$worksheet3->write(0, $i, 'Scroll down', $header);
}
for ($i=1;$i<=49;$i++) {
$worksheet3->write($i, 0, 'Scroll right', $header);
}
for ($i=1;$i<=49;$i++) {
for ($j=1;$j<=25;$j++) {
$worksheet3->write($i, $j, $j, $center);
}
}
#######################################################################
#
# Sheet 4
#
$worksheet4->set_selection('C3');
for ($i=1;$i<=25;$i++) {
$worksheet4->write(0, $i, 'Scroll', $center);
}
for ($i=1;$i<=49;$i++) {
$worksheet4->write($i, 0, 'Scroll', $center);
}
for ($i=1;$i<=49;$i++) {
for ($j=1;$j<=25;$j++) {
$worksheet4->write($i, $j, $j, $center);
}
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-panes.xls\"");
header("Content-Disposition: inline; filename=\"example-panes.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,29 +0,0 @@
<?php
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "repeat.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();
$worksheet->repeat_rows(0, 1);
$worksheet->write(0, 0, "Header line (will be repeated when printed)");
$worksheet->write(1, 0, "Header line number 2");
for ($i=1;$i<=100;$i++) {
$worksheet->write($i+1, 0, "Line $i");
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-repeat.xls\"");
header("Content-Disposition: inline; filename=\"example-repeat.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,40 +0,0 @@
<?php
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "simple.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();
# The general syntax is write($row, $column, $token). Note that row and
# column are zero indexed
#
# Write some text
$worksheet->write(0, 0, "Hi Excel!");
# Write some numbers
$worksheet->write(2, 0, 3); # Writes 3
$worksheet->write(3, 0, 3.00000); # Writes 3
$worksheet->write(4, 0, 3.00001); # Writes 3.00001
$worksheet->write(5, 0, 3.14159); # TeX revision no.?
# Write two formulas
$worksheet->write(7, 0, '=A3 + A6');
$worksheet->write(8, 0, '=IF(A5>3,"Yes", "No")');
# Write a hyperlink
$worksheet->write(10, 0, 'http://www.php.net/');
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-simple.xls\"");
header("Content-Disposition: inline; filename=\"example-simple.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,71 +0,0 @@
<?php
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "stocks.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet();
# Set the column width for columns 1, 2, 3 and 4
$worksheet->set_column(0, 3, 15);
# Create a format for the column headings
$header =& $workbook->addformat();
$header->set_bold();
$header->set_size(12);
$header->set_color('blue');
# Create a format for the stock price
$f_price =& $workbook->addformat();
$f_price->set_align('left');
$f_price->set_num_format('$0.00');
# Create a format for the stock volume
$f_volume =& $workbook->addformat();
$f_volume->set_align('left');
$f_volume->set_num_format('#,##0');
# Create a format for the price change. This is an example of a conditional
# format. The number is formatted as a percentage. If it is positive it is
# formatted in green, if it is negative it is formatted in red and if it is
# zero it is formatted as the default font colour (in this case black).
# Note: the [Green] format produces an unappealing lime green. Try
# [Color 10] instead for a dark green.
#
$f_change =& $workbook->addformat();
$f_change->set_align('left');
$f_change->set_num_format('[Green]0.0%;[Red]-0.0%;0.0%');
# Write out the data
$worksheet->write(0, 0, 'Company', $header);
$worksheet->write(0, 1, 'Price', $header);
$worksheet->write(0, 2, 'Volume', $header);
$worksheet->write(0, 3, 'Change', $header);
$worksheet->write(1, 0, 'Damage Inc.' );
$worksheet->write(1, 1, 30.25, $f_price); # $30.25
$worksheet->write(1, 2, 1234567, $f_volume); # 1,234,567
$worksheet->write(1, 3, 0.085, $f_change); # 8.5% in green
$worksheet->write(2, 0, 'Dump Corp.' );
$worksheet->write(2, 1, 1.56, $f_price); # $1.56
$worksheet->write(2, 2, 7564, $f_volume); # 7,564
$worksheet->write(2, 3, -0.015, $f_change); # -1.5% in red
$worksheet->write(3, 0, 'Rev Ltd.' );
$worksheet->write(3, 1, 0.13, $f_price); # $0.13
$worksheet->write(3, 2, 321, $f_volume); # 321
$worksheet->write(3, 3, 0, $f_change); # 0 in the font color (black)
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-stocks.xls\"");
header("Content-Disposition: inline; filename=\"example-stocks.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,72 +0,0 @@
<?php
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "textwrap.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();
# Set the column width for columns 1, 2 and 3
$worksheet->set_column(1, 1, 24);
$worksheet->set_column(2, 2, 34);
$worksheet->set_column(3, 3, 34);
# Set the row height for rows 1, 4, and 6. The heigt of row 2 will adjust
# automatically to fit the text.
#
$worksheet->set_row(0, 30);
$worksheet->set_row(3, 40);
$worksheet->set_row(5, 80);
# No newlines
$str1 = "For whatever we lose (like a you or a me) ";
$str1 .= "it's always ourselves we find in the sea";
# Embedded newlines
$str2 = "For whatever we lose\n(like a you or a me)\n";
$str2 .= "it's always ourselves\nwe find in the sea";
# Create a format for the column headings
$header =& $workbook->addformat();
$header->set_bold();
$header->set_font("Courier New");
$header->set_align('center');
$header->set_align('vcenter');
# Create a "vertical justification" format
$format1 =& $workbook->addformat();
$format1->set_align('vjustify');
# Create a "text wrap" format
$format2 =& $workbook->addformat();
$format2->set_text_wrap();
# Write the headers
$worksheet->write(0, 1, "set_align('vjustify')", $header);
$worksheet->write(0, 2, "set_align('vjustify')", $header);
$worksheet->write(0, 3, "set_text_wrap()", $header);
# Write some examples
$worksheet->write(1, 1, $str1, $format1);
$worksheet->write(1, 2, $str1, $format1);
$worksheet->write(1, 3, $str2, $format2);
$worksheet->write(3, 1, $str1, $format1);
$worksheet->write(3, 2, $str1, $format1);
$worksheet->write(3, 3, $str2, $format2);
$worksheet->write(5, 1, $str1, $format1);
$worksheet->write(5, 2, $str1, $format1);
$worksheet->write(5, 3, $str2, $format2);
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-textwrap.xls\"");
header("Content-Disposition: inline; filename=\"example-textwrap.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
?>

View File

@@ -1,120 +0,0 @@
<?php
define(PpsType_Root, 5);
define(PpsType_Dir, 1);
define(PpsType_File, 2);
define(DataSizeSmall, 0x1000);
define(LongIntSize, 4);
define(PpsSize, 0x80);
function Asc2Ucs($sAsc) {
return implode("\x00", (preg_split('//', $sAsc, -1, PREG_SPLIT_NO_EMPTY)))."\x00";
}
function Ucs2Asc($sUcs) {
$chars=explode("\x00", $sUcs);
array_pop($chars);
return implode("", $chars);
}
function OLEDate2Local($sDateTime) {
/* TODO!!!
//my($iSec, $iMin, $iHour, $iDay, $iMon, $iYear);
//my($iDate);
//my($iDt, $iYDays);
#1.Divide Day and Time
my $iBigDt = Math::BigInt->new(0);
foreach my $sWk (reverse(split //, $sDateTime)) {
$iBigDt *= 0x100;
$iBigDt += ord($sWk);
}
my $iHSec = $iBigDt % 10000000;
$iBigDt /= 10000000;
my $iBigDay = int($iBigDt / (24*3600)) + 1;
my $iTime = int($iBigDt % (24*3600));
#2. Year->Day(1601/1/2?)
$iDt = $iBigDay;
$iYear = 1601;
$iYDays = _yearDays($iYear); #Not 365 (365 days is Only in Excel World)
while($iDt > $iYDays) {
$iDt -= $iYDays;
$iYear++;
$iYDays = _yearDays($iYear);
}
my $iMD;
for($iMon=1;$iMon < 12; $iMon++){
$iMD = _monthDays($iMon, $iYear);
last if($iDt <= $iMD);
$iDt -= $iMD;
}
$iDay = $iDt;
#3. Hour->iSec
$iHour = int($iTime / 3600);
$iMin = int(($iTime % 3600) / 60);
$iSec = $iTime % 60;
return ($iSec, $iMin, $iHour, $iDay, $iMon - 1, $iYear-1900, $iHSec);
*/
}
#------------------------------------------------------------------------------
# Localtime->OLE Date
#------------------------------------------------------------------------------
function LocalDate2OLE($raDate) {
/* TODO!!!
if (!$raDate) {
return str_repeat("\x00", 8);
}
list($iSec, $iMin, $iHour, $iDay, $iMon, $iYear, $iHSec) = $raDate;
$iSec ||=0; $iMin ||=0; $iHour ||=0;
$iDay ||=0; $iMon ||=0; $iYear ||=0; $iHSec ||=0;
//my($iDate);
//my($iDt, $iYDays);
#1. Year -> Days
$iDate = -1;
for ($iY=1601;$iY<($iYear+1900);$iY++){
$iDate += _yearDays($iY);
}
for ($iM=0;$iM < $iMon;$iM++){
$iDate += _monthDays($iM+1, ($iYear+1900));
}
$iDate += $iDay;
#2. Hours->Sec + HighReso
my $iBigDt = Math::BigInt->new(0);
$iBigDt += $iHour*3600 + $iMin*60+ $iSec;
$iBigDt += ($iDate*(24*3600));
$iBigDt *= 10000000;
$iBigDt += $iHSec if($iHSec);
#3. Make HEX string
//my $iHex;
$sRes = '';
for($i=0;$i<8;$i++) {
$iHex = $iBigDt % 0x100;
$sRes .= pack('c', $iHex);
$iBigDt /= 0x100;
}
return $sRes;
*/
}
function _leapYear($iYear) {
return ((($iYear % 4)==0) && (($iYear % 100) || ($iYear % 400)==0)) ? 1 : 0;
}
function _yearDays($iYear) {
return _leapYear($iYear) ? 366 : 365;
}
function _monthDays($iMon, $iYear) {
if ($iMon == 1 || $iMon == 3 || $iMon == 5 || $iMon == 7 ||
$iMon == 8 || $iMon == 10 || $iMon == 12) {
return 31;
} elseif ($iMon == 4 || $iMon == 6 || $iMon == 9 || $iMon == 11) {
return 30;
} elseif ($iMon == 2) {
return _leapYear($iYear) ? 29 : 28;
}
}
?>

View File

@@ -1,271 +0,0 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
*/
/*
* Converts numeric $row/$col notation to an Excel cell reference string in
* A1 notation.
*/
function xl_rowcol_to_cell($row, $col, $row_abs=false, $col_abs=false) {
$row_abs = $row_abs ? '$' : '';
$col_abs = $col_abs ? '$' : '';
$int = floor($col / 26);
$frac = $col % 26;
$chr1 = ''; // Most significant character in AA1
if ($int > 0) {
$chr1 = chr(ord('A') + $int - 1);
}
$chr2 = chr(ord('A') + $frac);
// Zero index to 1-index
$row++;
return $col_abs.$chr1.$chr2.$row_abs.$row;
}
/*
* Converts an Excel cell reference string in A1 notation
* to numeric $row/$col notation.
*
* Returns: array($row, $col, $row_absolute, $col_absolute)
*
* The $row_absolute and $col_absolute parameters aren't documented because
* they are mainly used internally and aren't very useful to the user.
*/
function xl_cell_to_rowcol($cell) {
preg_match('/(\$?)([A-I]?[A-Z])(\$?)(\d+)/', $cell, $reg);
$col_abs = ($reg[1] == "") ? 0 : 1;
$col = $reg[2];
$row_abs = ($reg[3] == "") ? 0 : 1;
$row = $reg[4];
// Convert base26 column string to number
// All your Base are belong to us.
$chars = preg_split('//', $col, -1, PREG_SPLIT_NO_EMPTY);
$expn = 0;
$col = 0;
while (sizeof($chars)>0) {
$char = array_pop($chars); // Least significant character first
$col += (ord($char) - ord('A') + 1) * pow(26, $expn);
$expn++;
}
// Convert 1-index to zero-index
$row--;
$col--;
return array($row, $col, $row_abs, $col_abs);
}
/*
* Increments the row number of an Excel cell reference string
* in A1 notation.
* For example C4 to C5
*
* Returns: a cell reference string in A1 notation.
*/
function xl_inc_row($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell(++$row, $col, $row_abs, $col_abs);
}
/*
* Decrements the row number of an Excel cell reference string
* in A1 notation.
* For example C4 to C3
*
* Returns: a cell reference string in A1 notation.
*/
function xl_dec_row($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell(--$row, $col, $row_abs, $col_abs);
}
/*
* Increments the column number of an Excel cell reference string
* in A1 notation.
* For example C3 to D3
*
* Returns: a cell reference string in A1 notation.
*/
function xl_inc_col($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell($row, ++$col, $row_abs, $col_abs);
}
/*
* Decrements the column number of an Excel cell reference string
* in A1 notation.
* For example C3 to B3
*
* Returns: a cell reference string in A1 notation.
*/
function xl_dec_col($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell($row, --$col, $row_abs, $col_abs);
}
function xl_date_list($year, $month=1, $day=1,
$hour=0, $minute=0, $second=0) {
$monthdays=array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
// Leap years since 1900 (year is dividable by 4)
$leapyears=floor(($year-1900)/4);
// Non-leap years since 1900 (year is dividable by 100)
$nonleapyears=floor(($year-1900)/100);
// Non-non-leap years since 1900 (year is dividable by 400)
// (Yes, it MUST be "1600", not "1900")
$nonnonleapyears=floor(($year-1600)/400);
// Don't count the leap day of the specified year if it didn't
// happen yet (i.e. before 1 March)
//
// Please note that $leapyears becomes -1 for dates before 1 March 1900;
// this is not logical, but later we will add a day for Excel's
// phantasie leap day in 1900 without checking if the date is actually
// after 28 February 1900; so these two logic errors "neutralize"
// each other
if ($year%4==0 && $month<3) {
$leapyears--;
}
$days=365*($year-1900)+$leapyears-$nonleapyears+$nonnonleapyears;
for ($c=1;$c<$month;$c++) {
$days+=$monthdays[$c-1];
}
// Excel actually wants the days since 31 December 1899, not since
// 1 January 1900; this will also add this extra day
$days+=$day;
// Excel treats 1900 erroneously as a leap year, so we must
// add one day
//
// Please note that we DON'T have to check if the date is after
// 28 February 1900, because for such dates $leapyears is -1
// (see above)
$days++;
return (float)($days+($hour*3600+$minute*60+$second)/86400);
}
function xl_parse_time($time) {
if (preg_match('/(\d{1,2}):(\d\d):?((?:\d\d)(?:\.\d+)?)?(?:\s+)?(am|pm)?/i', $time, $reg)) {
$hours = $reg[1];
$minutes = $reg[2];
$seconds = $reg[3] || 0;
$meridian = strtolower($reg[4]) || '';
// Normalise midnight and midday
if ($hours == 12 && $meridian != '') {
$hours = 0;
}
// Add 12 hours to the pm times. Note: 12.00 pm has been set to 0.00.
if ($meridian == 'pm') {
$hours += 12;
}
// Calculate the time as a fraction of 24 hours in seconds
return (float)(($hours*3600+$minutes*60+$seconds)/86400);
} else {
return false; // Not a valid time string
}
}
/*
* Automagically converts almost any date/time string to an Excel date.
* This function will always only be as good as strtotime() is.
*/
function xl_parse_date($date) {
$unixtime=strtotime($date);
$year=date("Y", $unixtime);
$month=date("m", $unixtime);
$day=date("d", $unixtime);
$hour=date("H", $unixtime);
$minute=date("i", $unixtime);
$second=date("s", $unixtime);
// Convert to Excel date
return xl_date_list($year, $month, $day, $hour, $minute, $second);
}
/*
* Dummy function to be "compatible" to Spreadsheet::WriteExcel
*/
function xl_parse_date_init() {
// Erm... do nothing...
// strtotime() doesn't require anything to be initialized
// (do not ask me how to set the timezone...)
}
/*
* xl_decode_date_EU() and xl_decode_date_US() are mapped
* to xl_parse_date(); there seems to be no PHP function that
* differentiates between EU and US dates; I've never seen
* somebody using dd/mm/yyyy anyway, it always should be one of:
* - yyyy-mm-dd (international)
* - dd.mm.yyyy (european)
* - mm/dd/yyyy (english/US/british?)
*/
function xl_decode_date_EU($date) {
return xl_parse_date($date);
}
function xl_decode_date_US($date) {
return xl_parse_date($date);
}
function xl_date_1904($exceldate) {
if ($exceldate < 1462) {
// date is before 1904
$exceldate = 0;
} else {
$exceldate -= 1462;
}
return $exceldate;
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -1,202 +0,0 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/lib/viewfiles.lib.php
* \brief Set of function to view file content
* \version $Id: viewfiles.lib.php,v 1.8 2011/07/31 23:25:42 eldy Exp $
*/
/**
*
*/
function make_alpha_from_numbers($number)
{
$numeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if($number<dol_strlen($numeric))
{
return $numeric[$number];
}
else
{
$dev_by = floor($number/dol_strlen($numeric));
return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*dol_strlen($numeric)));
}
}
/**
* \brief Affiche le contenu d'un fichier CSV sous forme de tableau
* \param file_to_include Fichier CSV a afficher
* \param max_rows Nombre max de lignes a afficher (0 = illimit<69>)
*/
function viewCsvFileContent($file_to_include='',$max_rows=0)
{
$fic = fopen($file_to_include, 'rb');
$count = 0;
print '<table border="1">';
for ($line = fgetcsv($fic, 1024); (!feof($fic) && (($max_rows > 0)?($count<=$max_rows):1==1)); $line = fgetcsv($fic, 1024))
{
print '<tr>';
$j = sizeof($line);
for ($i = 0; $i < $j; $i++)
{
print '<td>'.$line[$i].'</td>';
}
print '</tr>';
$count++;
}
print '</table>';
}
/**
* \brief Affiche le contenu d'un fichier Excel (avec les feuilles de calcul) sous forme de tableau
* \param file_to_include Fichier Excel a afficher
* \param max_rows Nombre max de lignes a afficher (0 = illimite)
* \param max_cols Nombre max de colonnes a afficher (0 = illimite)
*/
function viewExcelFileContent($file_to_include='',$max_rows=0,$max_cols=0)
{
$debug = 0; //1 for on 0 for off
$force_nobr = 0; //Force the info in cells not to wrap unless stated explicitly (newline)
require_once(PHPEXCELREADER.'excelreader.php');
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CPa25a');
$data->read($file_to_include);
error_reporting(E_ALL ^ E_NOTICE);
echo "<script language='Javascript'>
var sheet_HTML = Array();\n";
for($sheet=0;$sheet<count($data->sheets);$sheet++)
{
$table_output[$sheet] .= "<TABLE CLASS='table_body'>
<TR>
<TD>&nbsp;</TD>";
for($i=0;$i < $data->sheets[$sheet]['numCols'] && (($i < $max_cols) || ($max_cols == 0));$i++)
{
$table_output[$sheet] .= "<TD CLASS='table_sub_heading' ALIGN=CENTER>" . make_alpha_from_numbers($i) . "</TD>";
}
for($row=1;$row<=$data->sheets[$sheet]['numRows']&&($row<=$max_rows||$max_rows==0);$row++)
{
$table_output[$sheet] .= "<TR><TD CLASS='table_sub_heading'>" . $row . "</TD>";
for($col=1;$col<=$data->sheets[$sheet]['numCols']&&($col<=$max_cols||$max_cols==0);$col++)
{
if($data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'] >=1 && $data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'] >=1)
{
$this_cell_colspan = " COLSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];
$this_cell_rowspan = " ROWSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];
for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];$i++)
{
$data->sheets[$sheet]['cellsInfo'][$row][$col+$i]['dontprint']=1;
}
for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];$i++)
{
for($j=0;$j<$data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];$j++)
{
$data->sheets[$sheet]['cellsInfo'][$row+$i][$col+$j]['dontprint']=1;
}
}
}
else if($data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'] >=1)
{
$this_cell_colspan = " COLSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];
$this_cell_rowspan = "";
for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];$i++)
{
$data->sheets[$sheet]['cellsInfo'][$row][$col+$i]['dontprint']=1;
}
}
else if($data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'] >=1)
{
$this_cell_colspan = "";
$this_cell_rowspan = " ROWSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];
for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];$i++)
{
$data->sheets[$sheet]['cellsInfo'][$row+$i][$col]['dontprint']=1;
}
}
else
{
$this_cell_colspan = "";
$this_cell_rowspan = "";
}
if(!($data->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']))
{
$table_output[$sheet] .= "<TD CLASS='table_data' $this_cell_colspan $this_cell_rowspan>&nbsp;";
if($force_nobr)
{
$table_output[$sheet] .= "<NOBR>";
}
$table_output[$sheet] .= nl2br(htmlentities($data->sheets[$sheet]['cells'][$row][$col]));
if($force_nobr)
{
$table_output[$sheet] .= "</NOBR>";
}
$table_output[$sheet] .= "</TD>";
}
}
$table_output[$sheet] .= "</TR>";
}
$table_output[$sheet] .= "</TABLE>";
$table_output[$sheet] = str_replace("\n","",$table_output[$sheet]);
$table_output[$sheet] = str_replace("\r","",$table_output[$sheet]);
$table_output[$sheet] = str_replace("\t"," ",$table_output[$sheet]);
if($debug)
{
$debug_output = print_r($data->sheets[$sheet],true);
$debug_output = str_replace("\n","\\n",$debug_output);
$debug_output = str_replace("\r","\\r",$debug_output);
$table_output[$sheet] .= "<PRE>$debug_output</PRE>";
}
echo "sheet_HTML[$sheet] = \"$table_output[$sheet]\";\n";
}
echo "
function change_tabs(sheet)
{
//alert('sheet_tab_' + sheet);
for(i=0;i<", count($data->sheets) , ";i++)
{
document.getElementById('sheet_tab_' + i).className = 'tab_base';
}
document.getElementById('table_loader_div').innerHTML=sheet_HTML[sheet];
document.getElementById('sheet_tab_' + sheet).className = 'tab_loaded';
}
</SCRIPT>";
echo "
<TABLE CLASS='table_body' NAME='tab_table'>
<TR>";
for($sheet=0;$sheet<count($data->sheets);$sheet++)
{
echo "<TD CLASS='tab_base' ID='sheet_tab_$sheet' ALIGN=CENTER
ONMOUSEDOWN=\"change_tabs($sheet);\">", $data->boundsheets[$sheet]['name'] , "</TD>";
}
echo
"<TR>";
echo "</TABLE>
<DIV ID=table_loader_div></DIV>
<SCRIPT LANGUAGE='JavaScript'>
change_tabs(0);
</SCRIPT>";
}
?>

View File

@@ -29,7 +29,7 @@
* \ingroup core
* \brief File that defines environment for all Dolibarr process (pages or scripts)
* This script reads the conf file, init $lang, $db and and empty $user
* \version $Id: master.inc.php,v 1.353 2011/08/11 12:14:03 eldy Exp $
* \version $Id: master.inc.php,v 1.354 2011/08/11 19:12:58 eldy Exp $
*/
@@ -203,7 +203,7 @@ if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
}
/*
* Create object $mysoc (A "Societe" object that contains properties of companies managed by Dolibarr.
* Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr.
*/
if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
{
@@ -281,38 +281,29 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
}
/*
* Set default language (must be after the setValues of $conf)
*/
// Set default language (must be after the setValues of $conf)
if (! defined('NOREQUIRETRAN'))
{
$langs->setDefaultLang($conf->global->MAIN_LANG_DEFAULT);
}
/*
* Pour utiliser d'autres versions des librairies externes que les
* versions embarquees dans Dolibarr, definir les constantes adequates:
* Pour FPDF: FPDF_PATH
* Pour PHP_WriteExcel: PHP_WRITEEXCEL_PATH
* Pour MagpieRss: MAGPIERSS_PATH
* Pour PHPlot: PHPLOT_PATH
* Pour JPGraph: JPGRAPH_PATH
* Pour NuSOAP: NUSOAP_PATH
* Pour TCPDF: TCPDF_PATH
*/
// Les path racines
if (! defined('FPDF_PATH')) { define('FPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdf/'); }
if (! defined('TCPDF_PATH')) { define('TCPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/tcpdf/'); }
if (! defined('FPDFI_PATH')) { define('FPDFI_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdfi/'); }
if (! defined('MAGPIERSS_PATH')) { define('MAGPIERSS_PATH', DOL_DOCUMENT_ROOT .'/includes/magpierss/'); }
if (! defined('NUSOAP_PATH')) { define('NUSOAP_PATH', DOL_DOCUMENT_ROOT .'/includes/nusoap/lib/'); }
if (! defined('PHP_WRITEEXCEL_PATH')) { define('PHP_WRITEEXCEL_PATH',DOL_DOCUMENT_ROOT .'/includes/php_writeexcel/'); }
if (! defined('PHPEXCELREADER')) { define('PHPEXCELREADER', DOL_DOCUMENT_ROOT .'/includes/phpexcelreader/'); }
// Les autres path
if (! defined('MAGPIE_DIR')) { define('MAGPIE_DIR', MAGPIERSS_PATH); }
if (! defined('MAGPIE_CACHE_DIR')) { define('MAGPIE_CACHE_DIR', $conf->externalrss->dir_temp); }
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');
/*
* To us other version of external libraries than embeded libraries, define here
* constant to path. Use '' to use include class path autodetect.
*/
// Path to root libraries
if (! defined('TCPDF_PATH')) { define('TCPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/tcpdf/'); }
if (! defined('FPDFI_PATH')) { define('FPDFI_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdfi/'); }
if (! defined('MAGPIERSS_PATH')) { define('MAGPIERSS_PATH', DOL_DOCUMENT_ROOT .'/includes/magpierss/'); }
if (! defined('NUSOAP_PATH')) { define('NUSOAP_PATH', DOL_DOCUMENT_ROOT .'/includes/nusoap/lib/'); }
if (! defined('PHPEXCEL_PATH')) { define('PHPEXCEL_PATH', DOL_DOCUMENT_ROOT .'/includes/phpexcel/'); }
// Other required path
if (! defined('MAGPIE_DIR')) { define('MAGPIE_DIR', MAGPIERSS_PATH); }
if (! defined('MAGPIE_CACHE_DIR')) { define('MAGPIE_CACHE_DIR', $conf->externalrss->dir_temp); }
// Old path to root deprecated (not used). Kept for extensions.
if (! defined('FPDF_PATH')) { define('FPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdf/'); }
if (! defined('PHP_WRITEEXCEL_PATH')) { define('PHP_WRITEEXCEL_PATH',DOL_DOCUMENT_ROOT .'/includes/php_writeexcel/'); }
?>

View File

@@ -2,7 +2,7 @@
<?php
/**
* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2011 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,8 +21,8 @@
/**
* \file scripts/company/export-contacts-xls-example.php
* \ingroup company
* \brief Export third parties' contacts with emails
* \version $Id: export-contacts-xls-example.php,v 1.8 2011/07/31 22:22:12 eldy Exp $
* \brief Script file to export contacts into an Excel file
* \version $Id: export-contacts-xls-example.php,v 1.9 2011/08/11 19:13:04 eldy Exp $
*/
$sapi_type = php_sapi_name();
@@ -42,29 +42,38 @@ if (! isset($argv[1]) || ! $argv[1]) {
$now=$argv[1];
// Recupere env dolibarr
$version='$Revision: 1.8 $';
$version='$Revision: 1.9 $';
require_once("../../htdocs/master.inc.php");
require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php");
require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
require_once($path."../../htdocs/master.inc.php");
//require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php");
//require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
require_once(PHPEXCEL_PATH."/PHPExcel.php");
//require_once(PHPEXCEL_PATH."/PHPExcel/Writer/Excel2007.php");
require_once(PHPEXCEL_PATH."/PHPExcel/Writer/Excel5.php");
$error = 0;
$fname = DOL_DATA_ROOT.'/export-contacts.xls';
$workbook = new writeexcel_workbook($fname);
//$objPHPExcel = new writeexcel_workbook($fname);
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
$objPHPExcel->getProperties()->setTitle("Test Document");
$objPHPExcel->getProperties()->setSubject("Test Document");
$objPHPExcel->getProperties()->setDescription("Test document, generated using PHP classes.");
$page = &$workbook->addworksheet('Export Dolibarr');
$page->set_column(0,4,18); // A
//$page = &$objPHPExcel->addworksheet('Export Dolibarr');
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle('Contacts');
$sql = "SELECT distinct c.email, c.name, c.firstname, s.nom ";
//$page->set_column(0,4,18); // A
$sql = "SELECT distinct c.name, c.firstname, c.email, s.nom";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.rowid = c.fk_soc";
$sql .= " AND c.email IS NOT NULL";
$sql .= " ORDER BY c.email ASC";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = c.fk_soc";
$resql=$db->query($sql);
if ($resql)
@@ -76,34 +85,40 @@ if ($resql)
$i = 0;
$j = 1;
$page->write_string(0, 0, $langs->trans("ThirdParty"));
$page->write_string(0, 1, $langs->trans("Firstname"));
$page->write_string(0, 2, $langs->trans("Lastname"));
$page->write_string(0, 3, $langs->trans("Email"));
$oldemail = "";
//$page->write_string(0, 0, $langs->trans("ThirdParty"));
$objPHPExcel->getActiveSheet()->SetCellValue('A1', $langs->trans("Firstname"));
//$page->write_string(0, 1, $langs->trans("Firstname"));
$objPHPExcel->getActiveSheet()->SetCellValue('B1', $langs->trans("Lastname"));
//$page->write_string(0, 2, $langs->trans("Lastname"));
$objPHPExcel->getActiveSheet()->SetCellValue('C1', $langs->trans("Email"));
//$page->write_string(0, 3, $langs->trans("Email"));
$objPHPExcel->getActiveSheet()->SetCellValue('D1', $langs->trans("ThirdPart"));
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($obj->email <> $oldemail)
{
$page->write_string($j, 0, $obj->nom);
$page->write_string($j, 1, $obj->firstname);
$page->write_string($j, 2, $obj->name);
$page->write_string($j, 3, $obj->email);
//$page->write_string($j, 0, $obj->nom);
$objPHPExcel->getActiveSheet()->SetCellValue('A'.($i+2), $obj->firstname);
//$page->write_string($j, 1, $obj->firstname);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.($i+2), $obj->name);
//$page->write_string($j, 2, $obj->name);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.($i+2), $obj->email);
//$page->write_string($j, 3, $obj->email);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.($i+2), $obj->nom);
$j++;
$oldemail = $obj->email;
}
$i++;
}
}
//$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save($fname);
//$objPHPExcel->close();
print 'File '.$fname.' was generated.'."\n";
}
$workbook->close();
?>

View File

@@ -20,7 +20,7 @@
<directory suffix=".php">../../htdocs/includes/ckeditor/</directory>
<directory suffix=".php">../../htdocs/includes/efc_xfss/</directory>
<directory suffix=".php">../../htdocs/includes/fckeditor/</directory>
<directory suffix=".php">../../htdocs/includes/fpdf/</directory>
<directory suffix=".php">../../htdocs/includes/fpdi/</directory>
<directory suffix=".php">../../htdocs/includes/geoip/</directory>
<directory suffix=".php">../../htdocs/includes/jquery/</directory>
<directory suffix=".php">../../htdocs/includes/jsgantt/</directory>
@@ -29,7 +29,6 @@
<directory suffix=".php">../../htdocs/includes/nusoap/</directory>
<directory suffix=".php">../../htdocs/includes/odtphp/</directory>
<directory suffix=".php">../../htdocs/includes/phpexcel/</directory>
<directory suffix=".php">../../htdocs/includes/php_writeexcel/</directory>
<directory suffix=".php">../../htdocs/includes/smtps/</directory>
<directory suffix=".php">../../htdocs/includes/tcpdf/</directory>
<directory suffix=".php">../../htdocs/includes/vcard/</directory>
@@ -64,7 +63,7 @@
<directory suffix=".php">../../htdocs/includes/barcode/php-barcode/</directory>
<directory suffix=".php">../../htdocs/includes/efc_xfss/</directory>
<directory suffix=".php">../../htdocs/includes/fckeditor/</directory>
<directory suffix=".php">../../htdocs/includes/fpdf/</directory>
<directory suffix=".php">../../htdocs/includes/fpdi/</directory>
<directory suffix=".php">../../htdocs/includes/geoip/</directory>
<directory suffix=".php">../../htdocs/includes/jcrop/</directory>
<directory suffix=".php">../../htdocs/includes/jquery/</directory>
@@ -74,7 +73,6 @@
<directory suffix=".php">../../htdocs/includes/nusoap/</directory>
<directory suffix=".php">../../htdocs/includes/odtphp/</directory>
<directory suffix=".php">../../htdocs/includes/phpexcel/</directory>
<directory suffix=".php">../../htdocs/includes/php_writeexcel/</directory>
<directory suffix=".php">../../htdocs/includes/smtps/</directory>
<directory suffix=".php">../../htdocs/includes/tcpdf/</directory>
<directory suffix=".php">../../htdocs/includes/vcard/</directory>