Merge branch 'develop' of https://github.com/PHPOffice/PhpSpreadsheet into develop
# Conflicts: # src/Autoloader.php
This commit is contained in:
commit
fb2edfdacf
|
@ -1,3 +1,2 @@
|
|||
/Build export-ignore
|
||||
/tests export-ignore
|
||||
README.md export-ignore
|
||||
|
|
1
.php_cs
1
.php_cs
|
@ -2,6 +2,7 @@
|
|||
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->exclude('vendor')
|
||||
->in('samples')
|
||||
->in('src')
|
||||
->in('tests');
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ before_script:
|
|||
|
||||
script:
|
||||
## PHP_CodeSniffer
|
||||
- ./vendor/bin/phpcs --report-width=200 --report-summary --report-full src/ tests/ --standard=PSR2 -n
|
||||
- ./vendor/bin/phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --standard=PSR2 -n
|
||||
## PHP-CS-Fixer
|
||||
- ./vendor/bin/php-cs-fixer fix --diff --verbose
|
||||
## PHPUnit
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
spl_autoload_register(function ($class) {
|
||||
include 'phar://PHPExcel/' . str_replace('_', '/', $class) . '.php';
|
||||
});
|
||||
|
||||
try {
|
||||
Phar::mapPhar();
|
||||
include 'phar://PHPExcel/PHPExcel.php';
|
||||
} catch (PharException $e) {
|
||||
error_log($e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
__HALT_COMPILER();
|
|
@ -1,2 +0,0 @@
|
|||
@ECHO OFF
|
||||
phing -f build.xml release-documentation
|
|
@ -1,2 +0,0 @@
|
|||
@ECHO OFF
|
||||
phing -f build.xml release-pear
|
|
@ -1,2 +0,0 @@
|
|||
@ECHO OFF
|
||||
phing -f build.xml release-phar
|
|
@ -1,2 +0,0 @@
|
|||
@ECHO OFF
|
||||
phing -f build.xml release-standard
|
216
Build/build.xml
216
Build/build.xml
|
@ -1,216 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="PHPExcel" default="release-standard" basedir=".">
|
||||
<target name="gather">
|
||||
<if>
|
||||
<isset property="${packageVersion}"/>
|
||||
<then>
|
||||
<echo message="PHPExcel version number is ${packageVersion}" />
|
||||
</then>
|
||||
<else>
|
||||
<propertyprompt propertyName="packageVersion" defaultValue="1.0.0"
|
||||
promptText="Enter PHPExcel version number"/>
|
||||
</else>
|
||||
</if>
|
||||
|
||||
<if>
|
||||
<isset property="${releaseDate}"/>
|
||||
<then>
|
||||
<echo message="Release date is ${releaseDate}" />
|
||||
</then>
|
||||
<else>
|
||||
<propertyprompt propertyName="releaseDate" defaultValue="2010-01-01"
|
||||
promptText="Enter PHPExcel release date"/>
|
||||
</else>
|
||||
</if>
|
||||
|
||||
<if>
|
||||
<isset property="${documentFormat}"/>
|
||||
<then>
|
||||
<echo message="Document Format is ${documentFormat}" />
|
||||
</then>
|
||||
<else>
|
||||
<propertyprompt propertyName="documentFormat" defaultValue="doc"
|
||||
promptText="Enter Document Format"/>
|
||||
</else>
|
||||
</if>
|
||||
</target>
|
||||
|
||||
<target name="prepare" depends="gather">
|
||||
<echo msg="Creating build directory: ./build"/>
|
||||
<mkdir dir="${phing.dir}/build"/>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="prepare">
|
||||
<echo msg="Copying source files to build directory..."/>
|
||||
|
||||
<copy todir="${phing.dir}/build/Classes" overwrite="true">
|
||||
<fileset dir="${phing.dir}/../Classes">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${phing.dir}/build/Examples" overwrite="true">
|
||||
<fileset dir="${phing.dir}/../Examples">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${phing.dir}/build/Documentation" overwrite="true">
|
||||
<fileset dir="${phing.dir}/../Documentation">
|
||||
<include name="*.${documentFormat}"/>
|
||||
<include name="*.txt"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<mkdir dir="${phing.dir}/build/Documentation/API"/>
|
||||
|
||||
<copy todir="${phing.dir}/build/Documentation/Examples" overwrite="true">
|
||||
<fileset dir="${phing.dir}/../Documentation/Examples">
|
||||
<include name="**/*"/>
|
||||
<exclude name="assets"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy file="${phing.dir}/../changelog.txt" tofile="${phing.dir}/build/changelog.txt" overwrite="true"/>
|
||||
<copy file="${phing.dir}/../license.md" tofile="${phing.dir}/build/license.txt" overwrite="true"/>
|
||||
<copy file="${phing.dir}/../install.txt" tofile="${phing.dir}/build/install.txt" overwrite="true"/>
|
||||
</target>
|
||||
|
||||
<target name="versionNumber" depends="build">
|
||||
<reflexive>
|
||||
<fileset dir="${phing.dir}/build">
|
||||
<include pattern="**/*"/>
|
||||
</fileset>
|
||||
<filterchain>
|
||||
<replaceregexp>
|
||||
<regexp pattern="##VERSION##" replace="${packageVersion}"/>
|
||||
<regexp pattern="##DATE##" replace="${releaseDate}"/>
|
||||
</replaceregexp>
|
||||
</filterchain>
|
||||
</reflexive>
|
||||
|
||||
<reflexive>
|
||||
<fileset dir="${phing.dir}/build">
|
||||
<include pattern="**/changelog.txt"/>
|
||||
</fileset>
|
||||
<filterchain>
|
||||
<replaceregexp>
|
||||
<regexp pattern="Fixed in develop branch for release v${packageVersion}" replace="${releaseDate} (v${packageVersion})"/>
|
||||
</replaceregexp>
|
||||
</filterchain>
|
||||
</reflexive>
|
||||
</target>
|
||||
|
||||
<target name="apidocs" depends="versionNumber">
|
||||
<echo msg="Generating API documentation..."/>
|
||||
<phpdoc2 title="PHPExcel classes"
|
||||
destdir="${phing.dir}/build/Documentation/API"
|
||||
template="responsive">
|
||||
<fileset dir="${phing.dir}/build/Classes">
|
||||
<include name="**/*.php"/>
|
||||
</fileset>
|
||||
</phpdoc2>
|
||||
</target>
|
||||
|
||||
<target name="release-standard" depends="apidocs">
|
||||
<mkdir dir="${phing.dir}/release"/>
|
||||
|
||||
<echo msg="Creating release package (v${packageVersion} with ${documentFormat} documents)..."/>
|
||||
<zip destfile="${phing.dir}/release/PHPExcel_${packageVersion}_${documentFormat}.zip">
|
||||
<fileset dir="${phing.dir}/build">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</zip>
|
||||
|
||||
<echo msg="Cleaning build directory: ./build"/>
|
||||
<delete dir="${phing.dir}/build"/>
|
||||
</target>
|
||||
|
||||
<target name="release-phar" depends="versionNumber">
|
||||
<mkdir dir="${phing.dir}/release"/>
|
||||
|
||||
<echo msg="Creating PHAR release package (v${packageVersion})..."/>
|
||||
<pharpackage destfile="${phing.dir}/release/PHPExcel_${packageVersion}.phar" basedir="${phing.dir}/build/Classes" compression="gzip" stub="${phing.dir}/PharStub.php">
|
||||
<fileset dir="${phing.dir}/build/Classes">
|
||||
<include name="**/**" />
|
||||
</fileset>
|
||||
<metadata>
|
||||
<element name="version" value="${packageVersion}" />
|
||||
<element name="date" value="${releaseDate}" />
|
||||
<element name="description" value="A pure PHP library for reading and writing spreadsheet files" />
|
||||
<element name="authors">
|
||||
<element name="Mark Baker">
|
||||
<element name="e-mail" value="mark@lange.demon.co.uk" />
|
||||
</element>
|
||||
</element>
|
||||
</metadata>
|
||||
</pharpackage>
|
||||
|
||||
<echo msg="Cleaning build directory: ./build"/>
|
||||
<delete dir="${phing.dir}/build"/>
|
||||
</target>
|
||||
|
||||
<target name="release-pear" depends="versionNumber">
|
||||
<taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2"/>
|
||||
|
||||
<mkdir dir="${phing.dir}/release"/>
|
||||
|
||||
<echo msg="Creating PEAR release package (v${packageVersion})..."/>
|
||||
|
||||
<d51pearpkg2 dir="${phing.dir}/build/Classes" baseinstalldir="PHPExcel">
|
||||
<name>PHPExcel</name>
|
||||
<summary>PHP Excel classes</summary>
|
||||
<channel>pear.pearplex.net</channel>
|
||||
<description>Project providing a set of classes for the PHP programming language, which allow you to write
|
||||
to Excel 2007 files and read from Excel 2007 files.
|
||||
</description>
|
||||
<notes>This package ONLY contains the class files, not the documentation and example code. Please refer to
|
||||
http://www.codeplex.com/PHPExcel for those files.
|
||||
</notes>
|
||||
<lead user="maartenba" name="Maarten Balliauw" email="maarten@phpexcel.net"/>
|
||||
<license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt">LGPL</license>
|
||||
<version release="${packageVersion}" api="${packageVersion}"/>
|
||||
<stability release="stable" api="stable"/>
|
||||
<dependencies>
|
||||
<php minimum_version="5.2.0"/>
|
||||
<pear minimum_version="1.4.0"/>
|
||||
<extension name="zip" minimum_version="1.8.0"/>
|
||||
</dependencies>
|
||||
<dirroles key="PHPExcel/Shared/PDF/fonts">data</dirroles>
|
||||
<dirroles key="PHPExcel/Shared/PDF/fonts/utils">data</dirroles>
|
||||
<dirroles key="/PHPExcel/Shared/PDF/fonts/utils">data</dirroles>
|
||||
</d51pearpkg2>
|
||||
|
||||
<exec command="pear package ${phing.dir}/build/Classes/package.xml"/>
|
||||
<move file="PHPExcel-${packageVersion}.tgz" tofile="${phing.dir}/release/PHPExcel-${packageVersion}.tgz" overwrite="true"/>
|
||||
|
||||
<echo msg="Cleaning build directory: ./build"/>
|
||||
<delete dir="${phing.dir}/build"/>
|
||||
</target>
|
||||
|
||||
<target name="release-documentation" depends="gather">
|
||||
<mkdir dir="${phing.dir}/release"/>
|
||||
|
||||
<echo msg="Creating documentation release (v${packageVersion} with ${documentFormat} documents)..."/>
|
||||
<copy todir="${phing.dir}/build" overwrite="true">
|
||||
<fileset dir="${phing.dir}/../Documentation">
|
||||
<include name="*.${documentFormat}"/>
|
||||
<include name="*.txt"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${phing.dir}/build/Examples" overwrite="true">
|
||||
<fileset dir="${phing.dir}/../Documentation/Examples">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<echo msg="Creating documentation release package (v${packageVersion} with ${documentFormat} documents)..."/>
|
||||
<zip destfile="${phing.dir}/release/PHPExcel_${packageVersion}-documentation_${documentFormat}.zip">
|
||||
<fileset dir="${phing.dir}/build">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</zip>
|
||||
|
||||
<echo msg="Cleaning build directory: ./build"/>
|
||||
<delete dir="${phing.dir}/build"/>
|
||||
</target>
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
# PHPExcel AutoFilter Reference
|
||||
# PHPExcel AutoFilter Reference
|
||||
|
||||
|
||||
## AutoFilters
|
||||
|
@ -7,7 +7,7 @@ Each worksheet in an Excel Workbook can contain a single autoFilter range. Filte
|
|||
|
||||
![01-01-autofilter.png](./images/01-01-autofilter.png "")
|
||||
|
||||
When an AutoFilter is applied to a range of cells, the first row in an autofilter range will be the heading row, which displays the autoFilter dropdown icons. It is not part of the actual autoFiltered data. All subsequent rows are the autoFiltered data. So an AutoFilter range should always contain the heading row and one or more data rows (one data row is pretty meaningless), but PHPExcel won't actually stop you specifying a meaningless range: it's up to you as the developer to avoid such errors.
|
||||
When an AutoFilter is applied to a range of cells, the first row in an autofilter range will be the heading row, which displays the autoFilter dropdown icons. It is not part of the actual autoFiltered data. All subsequent rows are the autoFiltered data. So an AutoFilter range should always contain the heading row and one or more data rows (one data row is pretty meaningless), but PHPExcel won't actually stop you specifying a meaningless range: it's up to you as a developer to avoid such errors.
|
||||
|
||||
To determine if a filter is applied, note the icon in the column heading. A drop-down arrow (![01-03-filter-icon-1.png](./images/01-03-filter-icon-1.png "")) means that filtering is enabled but not applied. In MS Excel, when you hover over the heading of a column with filtering enabled but not applied, a screen tip displays the cell text for the first row in that column, and the message "(Showing All)".
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# PHPExcel AutoFilter Reference
|
||||
# PHPExcel AutoFilter Reference
|
||||
|
||||
|
||||
## Setting an AutoFilter area on a worksheet
|
||||
|
@ -9,7 +9,7 @@ To set an autoFilter on a range of cells.
|
|||
$objPHPExcel->getActiveSheet()->setAutoFilter('A1:E20');
|
||||
```
|
||||
|
||||
The first row in an autofilter range will be the heading row, which displays the autoFilter dropdown icons. It is not part of the actual autoFiltered data. All subsequent rows are the autoFiltered data. So an AutoFilter range should always contain the heading row and one or more data rows (one data row is pretty meaningless, but PHPExcel won't actually stop you specifying a meaningless range: it's up to you as the developer to avoid such errors.
|
||||
The first row in an autofilter range will be the heading row, which displays the autoFilter dropdown icons. It is not part of the actual autoFiltered data. All subsequent rows are the autoFiltered data. So an AutoFilter range should always contain the heading row and one or more data rows (one data row is pretty meaningless, but PHPExcel won't actually stop you specifying a meaningless range: it's up to you as a developer to avoid such errors.
|
||||
|
||||
If you want to set the whole worksheet as an autofilter region
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
*.xls
|
||||
*.xlsx
|
||||
*.csv
|
||||
*.jpg
|
||||
*.pdf
|
||||
*.htm
|
||||
*.html
|
||||
*.log
|
||||
!.gitignore
|
||||
!data/**
|
||||
!images/**
|
||||
!templates/**
|
|
@ -1,112 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once '../Build/PHPExcel.phar';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("PHPExcel Test Document")
|
||||
->setSubject("PHPExcel Test Document")
|
||||
->setDescription("Test document for PHPExcel, generated using PHP classes.")
|
||||
->setKeywords("office PHPExcel php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
if (PHP_SAPI == 'cli')
|
||||
die('This example should only be run from a Web Browser');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$objPhpSpreadsheet->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename worksheet
|
||||
$objPhpSpreadsheet->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Redirect output to a client’s web browser (OpenDocument)
|
||||
header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
|
||||
header('Content-Disposition: attachment;filename="01simple.ods"');
|
||||
header('Cache-Control: max-age=0');
|
||||
// If you're serving to IE 9, then the following may be needed
|
||||
header('Cache-Control: max-age=1');
|
||||
|
||||
// If you're serving to IE over SSL, then the following may be needed
|
||||
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
|
||||
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header ('Pragma: public'); // HTTP/1.0
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'OpenDocument');
|
||||
$objWriter->save('php://output');
|
||||
exit;
|
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
if (PHP_SAPI == 'cli')
|
||||
die('This example should only be run from a Web Browser');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Change these values to select the Rendering library that you wish to use
|
||||
// and its directory location on your server
|
||||
//$rendererName = PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF;
|
||||
$rendererName = PhpSpreadsheet\Settings::PDF_RENDERER_MPDF;
|
||||
//$rendererName = PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF;
|
||||
//$rendererLibrary = 'tcPDF5.9';
|
||||
$rendererLibrary = 'mPDF5.4';
|
||||
//$rendererLibrary = 'domPDF0.6.0beta3';
|
||||
$rendererLibraryPath = dirname(__FILE__).'/../../../libraries/PDF/' . $rendererLibrary;
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$objPhpSpreadsheet->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("PDF Test Document")
|
||||
->setSubject("PDF Test Document")
|
||||
->setDescription("Test document for PDF, generated using PHP classes.")
|
||||
->setKeywords("pdf php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename worksheet
|
||||
$objPhpSpreadsheet->getActiveSheet()->setTitle('Simple');
|
||||
$objPhpSpreadsheet->getActiveSheet()->setShowGridLines(false);
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
if (!PhpSpreadsheet\Settings::setPdfRenderer(
|
||||
$rendererName,
|
||||
$rendererLibraryPath
|
||||
)) {
|
||||
die(
|
||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||
'<br />' .
|
||||
'at the top of this script as appropriate for your directory structure'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Redirect output to a client’s web browser (PDF)
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: attachment;filename="01simple.pdf"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'PDF');
|
||||
$objWriter->save('php://output');
|
||||
exit;
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
if (PHP_SAPI == 'cli')
|
||||
die('This example should only be run from a Web Browser');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$objPhpSpreadsheet->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename worksheet
|
||||
$objPhpSpreadsheet->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Redirect output to a client’s web browser (Excel5)
|
||||
header('Content-Type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment;filename="01simple.xls"');
|
||||
header('Cache-Control: max-age=0');
|
||||
// If you're serving to IE 9, then the following may be needed
|
||||
header('Cache-Control: max-age=1');
|
||||
|
||||
// If you're serving to IE over SSL, then the following may be needed
|
||||
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
|
||||
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header ('Pragma: public'); // HTTP/1.0
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel5');
|
||||
$objWriter->save('php://output');
|
||||
exit;
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
if (PHP_SAPI == 'cli')
|
||||
die('This example should only be run from a Web Browser');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$objPhpSpreadsheet->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
// Rename worksheet
|
||||
$objPhpSpreadsheet->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Redirect output to a client’s web browser (Excel2007)
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="01simple.xlsx"');
|
||||
header('Cache-Control: max-age=0');
|
||||
// If you're serving to IE 9, then the following may be needed
|
||||
header('Cache-Control: max-age=1');
|
||||
|
||||
// If you're serving to IE over SSL, then the following may be needed
|
||||
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
|
||||
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header ('Pragma: public'); // HTTP/1.0
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel2007');
|
||||
$objWriter->save('php://output');
|
||||
exit;
|
|
@ -1,140 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new Spreadsheet object
|
||||
echo date('H:i:s') , " Create new Spreadsheet object" , EOL;
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPhpSpreadsheet->getProperties()
|
||||
->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("PhpSpreadsheet Test Document")
|
||||
->setSubject("PhpSpreadsheet Test Document")
|
||||
->setDescription("Test document for PhpSpreadsheet, generated using PHP classes.")
|
||||
->setKeywords("office PhpSpreadsheet php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A8',"Hello\nWorld");
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getRowDimension(8)
|
||||
->setRowHeight(-1);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getStyle('A8')
|
||||
->getAlignment()
|
||||
->setWrapText(true);
|
||||
|
||||
|
||||
$value = "-ValueA\n-Value B\n-Value C";
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A10', $value);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getRowDimension(10)
|
||||
->setRowHeight(-1);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getStyle('A10')
|
||||
->getAlignment()
|
||||
->setWrapText(true);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getStyle('A10')
|
||||
->setQuotePrefix(true);
|
||||
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setTitle('Simple');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
echo date('H:i:s') , " Create new PhpSpreadsheet object" , EOL;
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPhpSpreadsheet->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("PhpSpreadsheet Test Document")
|
||||
->setSubject("PhpSpreadsheet Test Document")
|
||||
->setDescription("Test document for PhpSpreadsheet, generated using PHP classes.")
|
||||
->setKeywords("office PhpSpreadsheet php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()->setCellValue('A8',"Hello\nWorld");
|
||||
$objPhpSpreadsheet->getActiveSheet()->getRowDimension(8)->setRowHeight(-1);
|
||||
$objPhpSpreadsheet->getActiveSheet()->getStyle('A8')->getAlignment()->setWrapText(true);
|
||||
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
// Use PCLZip rather than ZipArchive to create the Excel2007 OfficeOpenXML file
|
||||
PhpSpreadsheet\Settings::setZipClass(PhpSpreadsheet\Settings::PCLZIP);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,229 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2016 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
echo date('H:i:s') , " Create new PhpSpreadsheet object" , EOL;
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPhpSpreadsheet->getProperties()
|
||||
->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
// Set default font
|
||||
echo date('H:i:s') , " Set default font" , EOL;
|
||||
$objPhpSpreadsheet->getDefaultStyle()
|
||||
->getFont()
|
||||
->setName('Arial')
|
||||
->setSize(10);
|
||||
|
||||
// Add some data, resembling some different data types
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A1', 'String')
|
||||
->setCellValue('B1', 'Simple')
|
||||
->setCellValue('C1', 'PhpSpreadsheet');
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A2', 'String')
|
||||
->setCellValue('B2', 'Symbols')
|
||||
->setCellValue('C2', '!+&=()~§±æþ');
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A3', 'String')
|
||||
->setCellValue('B3', 'UTF-8')
|
||||
->setCellValue('C3', 'Создать MS Excel Книги из PHP скриптов');
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A4', 'Number')
|
||||
->setCellValue('B4', 'Integer')
|
||||
->setCellValue('C4', 12);
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A5', 'Number')
|
||||
->setCellValue('B5', 'Float')
|
||||
->setCellValue('C5', 34.56);
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A6', 'Number')
|
||||
->setCellValue('B6', 'Negative')
|
||||
->setCellValue('C6', -7.89);
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A7', 'Boolean')
|
||||
->setCellValue('B7', 'True')
|
||||
->setCellValue('C7', true);
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A8', 'Boolean')
|
||||
->setCellValue('B8', 'False')
|
||||
->setCellValue('C8', false);
|
||||
|
||||
$dateTimeNow = time();
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A9', 'Date/Time')
|
||||
->setCellValue('B9', 'Date')
|
||||
->setCellValue('C9', \PhpSpreadsheet\Shared\Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getStyle('C9')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A10', 'Date/Time')
|
||||
->setCellValue('B10', 'Time')
|
||||
->setCellValue('C10', \PhpSpreadsheet\Shared\Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getStyle('C10')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4);
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A11', 'Date/Time')
|
||||
->setCellValue('B11', 'Date and Time')
|
||||
->setCellValue('C11', \PhpSpreadsheet\Shared\Date::PHPToExcel( $dateTimeNow ));
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getStyle('C11')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A12', 'NULL')
|
||||
->setCellValue('C12', NULL);
|
||||
|
||||
$objRichText = new \PhpSpreadsheet\RichText();
|
||||
$objRichText->createText('你好 ');
|
||||
|
||||
$objPayable = $objRichText->createTextRun('你 好 吗?');
|
||||
$objPayable->getFont()->setBold(true);
|
||||
$objPayable->getFont()->setItalic(true);
|
||||
$objPayable->getFont()->setColor( new \PhpSpreadsheet\Style\Color( \PhpSpreadsheet\Style\Color::COLOR_DARKGREEN ) );
|
||||
|
||||
$objRichText->createText(', unless specified otherwise on the invoice.');
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A13', 'Rich Text')
|
||||
->setCellValue('C13', $objRichText);
|
||||
|
||||
|
||||
$objRichText2 = new \PhpSpreadsheet\RichText();
|
||||
$objRichText2->createText("black text\n");
|
||||
|
||||
$objRed = $objRichText2->createTextRun("red text");
|
||||
$objRed->getFont()->setColor( new \PhpSpreadsheet\Style\Color(\PhpSpreadsheet\Style\Color::COLOR_RED ) );
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell("C14")
|
||||
->setValue($objRichText2);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getStyle("C14")
|
||||
->getAlignment()->setWrapText(true);
|
||||
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()->setCellValue('A17', 'Hyperlink');
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('C17', 'PhpSpreadsheet Web Site');
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell('C17')
|
||||
->getHyperlink()
|
||||
->setUrl('https://github.com/PHPOffice/PhpSpreadsheet')
|
||||
->setTooltip('Navigate to PhpSpreadsheet website');
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('C18', '=HYPERLINK("mailto:abc@def.com","abc@def.com")');
|
||||
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getColumnDimension('B')
|
||||
->setAutoSize(true);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getColumnDimension('C')
|
||||
->setAutoSize(true);
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()->setTitle('Datatypes');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 5 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done testing file" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,175 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @package PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
echo date('H:i:s') , " Create new PhpSpreadsheet object" , EOL;
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPhpSpreadsheet->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A5', 'Sum:');
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()->setCellValue('B1', 'Range #1')
|
||||
->setCellValue('B2', 3)
|
||||
->setCellValue('B3', 7)
|
||||
->setCellValue('B4', 13)
|
||||
->setCellValue('B5', '=SUM(B2:B4)');
|
||||
echo date('H:i:s') , " Sum of Range #1 is " ,
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell('B5')
|
||||
->getCalculatedValue() , EOL;
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()->setCellValue('C1', 'Range #2')
|
||||
->setCellValue('C2', 5)
|
||||
->setCellValue('C3', 11)
|
||||
->setCellValue('C4', 17)
|
||||
->setCellValue('C5', '=SUM(C2:C4)');
|
||||
echo date('H:i:s') , " Sum of Range #2 is " ,
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell('C5')
|
||||
->getCalculatedValue() , EOL;
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A7', 'Total of both ranges:');
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('B7', '=SUM(B5:C5)');
|
||||
echo date('H:i:s') , " Sum of both Ranges is " ,
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell('B7')
|
||||
->getCalculatedValue() , EOL;
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A8', 'Minimum of both ranges:');
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('B8', '=MIN(B2:C4)');
|
||||
echo date('H:i:s') , " Minimum value in either Range is " ,
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell('B8')
|
||||
->getCalculatedValue() , EOL;
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A9', 'Maximum of both ranges:');
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('B9', '=MAX(B2:C4)');
|
||||
echo date('H:i:s') , " Maximum value in either Range is " ,
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell('B9')
|
||||
->getCalculatedValue() , EOL;
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('A10', 'Average of both ranges:');
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setCellValue('B10', '=AVERAGE(B2:C4)');
|
||||
echo date('H:i:s') , " Average value of both Ranges is " ,
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getCell('B10')->getCalculatedValue() , EOL;
|
||||
|
||||
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getColumnDimension('A')
|
||||
->setAutoSize(true);
|
||||
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->setTitle('Formulas');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel2007');
|
||||
|
||||
//
|
||||
// If we set Pre Calculated Formulas to true then PhpSpreadsheet will calculate all formulae in the
|
||||
// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
|
||||
// using functions or features (such as array formulae) that aren't yet supported by the calculation engine
|
||||
// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to
|
||||
// open the file) will need to recalculate values itself to guarantee that the correct results are available.
|
||||
//
|
||||
//$objWriter->setPreCalculateFormulas(true);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PhpSpreadsheet
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PhpSpreadsheet
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PhpSpreadsheet
|
||||
* @package PhpSpreadsheet
|
||||
* @copyright Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PhpSpreadsheet */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
echo date('H:i:s') , " Create new PhpSpreadsheet object" , EOL;
|
||||
$objPhpSpreadsheet = new \PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPhpSpreadsheet->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data, we will use printing features
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
for ($i = 1; $i < 200; $i++) {
|
||||
$objPhpSpreadsheet->getActiveSheet()->setCellValue('A' . $i, $i);
|
||||
$objPhpSpreadsheet->getActiveSheet()->setCellValue('B' . $i, 'Test value');
|
||||
}
|
||||
|
||||
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
|
||||
echo date('H:i:s') , " Set header/footer" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getHeaderFooter()
|
||||
->setOddHeader('&L&G&C&HPlease treat this document as confidential!');
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getHeaderFooter()
|
||||
->setOddFooter('&L&B' . $objPhpSpreadsheet->getProperties()->getTitle() . '&RPage &P of &N');
|
||||
|
||||
// Add a drawing to the header
|
||||
echo date('H:i:s') , " Add a drawing to the header" , EOL;
|
||||
$objDrawing = new \PhpSpreadsheet\Worksheet\HeaderFooterDrawing();
|
||||
$objDrawing->setName('PhpSpreadsheet logo');
|
||||
$objDrawing->setPath('./images/PhpSpreadsheet_logo.gif');
|
||||
$objDrawing->setHeight(36);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getHeaderFooter()
|
||||
->addImage($objDrawing, \PhpSpreadsheet\Worksheet\HeaderFooter::IMAGE_HEADER_LEFT);
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') , " Set page orientation and size" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getPageSetup()
|
||||
->setOrientation(\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$objPhpSpreadsheet->getActiveSheet()
|
||||
->getPageSetup()
|
||||
->setPaperSize(\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPhpSpreadsheet->getActiveSheet()->setTitle('Printing');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPhpSpreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,394 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet, representing sales data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', \PHPExcel\Shared\Date::PHPToExcel( gmmktime(0,0,0,date('m'),date('d'),date('Y')) ));
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D1')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_XLSX15);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', '#12566');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Product Id');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', 'Description');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', 'Price');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D3', 'Amount');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E3', 'Total');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', '1001');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'PHP for dummies');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', '20');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D4', '1');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E4', '=IF(D4<>"",C4*D4,"")');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', '1012');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'OpenXML for dummies');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', '22');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D5', '2');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E5', '=IF(D5<>"",C5*D5,"")');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E6', '=IF(D6<>"",C6*D6,"")');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E7', '=IF(D7<>"",C7*D7,"")');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E8', '=IF(D8<>"",C8*D8,"")');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E9', '=IF(D9<>"",C9*D9,"")');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D11', 'Total excl.:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E11', '=SUM(E4:E9)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D12', 'VAT:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E12', '=E11*0.21');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D13', 'Total incl.:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E13', '=E11+E12');
|
||||
|
||||
// Add comment
|
||||
echo date('H:i:s') , " Add comments" , EOL;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel');
|
||||
$objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:');
|
||||
$objCommentRichText->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun("\r\n");
|
||||
$objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('Total amount on the current invoice, excluding VAT.');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getComment('E12')->setAuthor('PHPExcel');
|
||||
$objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun('PHPExcel:');
|
||||
$objCommentRichText->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun("\r\n");
|
||||
$objPHPExcel->getActiveSheet()->getComment('E12')->getText()->createTextRun('Total amount of VAT on the current invoice.');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getComment('E13')->setAuthor('PHPExcel');
|
||||
$objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun('PHPExcel:');
|
||||
$objCommentRichText->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun("\r\n");
|
||||
$objPHPExcel->getActiveSheet()->getComment('E13')->getText()->createTextRun('Total amount on the current invoice, including VAT.');
|
||||
$objPHPExcel->getActiveSheet()->getComment('E13')->setWidth('100pt');
|
||||
$objPHPExcel->getActiveSheet()->getComment('E13')->setHeight('100pt');
|
||||
$objPHPExcel->getActiveSheet()->getComment('E13')->setMarginLeft('150pt');
|
||||
$objPHPExcel->getActiveSheet()->getComment('E13')->getFillColor()->setRGB('EEEEEE');
|
||||
|
||||
|
||||
// Add rich-text string
|
||||
echo date('H:i:s') , " Add rich-text string" , EOL;
|
||||
$objRichText = new \PHPExcel\RichText();
|
||||
$objRichText->createText('This invoice is ');
|
||||
|
||||
$objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month');
|
||||
$objPayable->getFont()->setBold(true);
|
||||
$objPayable->getFont()->setItalic(true);
|
||||
$objPayable->getFont()->setColor(new \PHPExcel\Style\Color(\PHPExcel\Style\Color::COLOR_DARKGREEN));
|
||||
|
||||
$objRichText->createText(', unless specified otherwise on the invoice.');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);
|
||||
|
||||
// Merge cells
|
||||
echo date('H:i:s') , " Merge cells" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->mergeCells('A18:E22');
|
||||
$objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test...
|
||||
$objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test...
|
||||
|
||||
// Protect cells
|
||||
echo date('H:i:s') , " Protect cells" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection!
|
||||
$objPHPExcel->getActiveSheet()->protectCells('A3:E13', 'PHPExcel');
|
||||
|
||||
// Set cell number formats
|
||||
echo date('H:i:s') , " Set cell number formats" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
// Set column widths
|
||||
echo date('H:i:s') , " Set column widths" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12);
|
||||
|
||||
// Set fonts
|
||||
echo date('H:i:s') , " Set fonts" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara');
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setUnderline(\PHPExcel\Style\Font::UNDERLINE_SINGLE);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_WHITE);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D1')->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_WHITE);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E1')->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_WHITE);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D13')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E13')->getFont()->setBold(true);
|
||||
|
||||
// Set alignments
|
||||
echo date('H:i:s') , " Set alignments" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_JUSTIFY);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setVertical(\PHPExcel\Style\Alignment::VERTICAL_CENTER);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true);
|
||||
|
||||
// Set thin black border outline around column
|
||||
echo date('H:i:s') , " Set thin black border outline around column" , EOL;
|
||||
$styleThinBlackBorderOutline = array(
|
||||
'borders' => array(
|
||||
'outline' => array(
|
||||
'style' => \PHPExcel\Style\Border::BORDER_THIN,
|
||||
'color' => array('argb' => 'FF000000'),
|
||||
),
|
||||
),
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A4:E10')->applyFromArray($styleThinBlackBorderOutline);
|
||||
|
||||
|
||||
// Set thick brown border outline around "Total"
|
||||
echo date('H:i:s') , " Set thick brown border outline around Total" , EOL;
|
||||
$styleThickBrownBorderOutline = array(
|
||||
'borders' => array(
|
||||
'outline' => array(
|
||||
'style' => \PHPExcel\Style\Border::BORDER_THICK,
|
||||
'color' => array('argb' => 'FF993300'),
|
||||
),
|
||||
),
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickBrownBorderOutline);
|
||||
|
||||
// Set fills
|
||||
echo date('H:i:s') , " Set fills" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(\PHPExcel\Style\Fill::FILL_SOLID);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->setARGB('FF808080');
|
||||
|
||||
// Set style for header row using alternative method
|
||||
echo date('H:i:s') , " Set style for header row using alternative method" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray(
|
||||
array(
|
||||
'font' => array(
|
||||
'bold' => true
|
||||
),
|
||||
'alignment' => array(
|
||||
'horizontal' => \PHPExcel\Style\Alignment::HORIZONTAL_RIGHT,
|
||||
),
|
||||
'borders' => array(
|
||||
'top' => array(
|
||||
'style' => \PHPExcel\Style\Border::BORDER_THIN
|
||||
)
|
||||
),
|
||||
'fill' => array(
|
||||
'type' => \PHPExcel\Style\Fill::FILL_GRADIENT_LINEAR,
|
||||
'rotation' => 90,
|
||||
'startcolor' => array(
|
||||
'argb' => 'FFA0A0A0'
|
||||
),
|
||||
'endcolor' => array(
|
||||
'argb' => 'FFFFFFFF'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray(
|
||||
array(
|
||||
'alignment' => array(
|
||||
'horizontal' => \PHPExcel\Style\Alignment::HORIZONTAL_LEFT,
|
||||
),
|
||||
'borders' => array(
|
||||
'left' => array(
|
||||
'style' => \PHPExcel\Style\Border::BORDER_THIN
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B3')->applyFromArray(
|
||||
array(
|
||||
'alignment' => array(
|
||||
'horizontal' => \PHPExcel\Style\Alignment::HORIZONTAL_LEFT,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray(
|
||||
array(
|
||||
'borders' => array(
|
||||
'right' => array(
|
||||
'style' => \PHPExcel\Style\Border::BORDER_THIN
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Unprotect a cell
|
||||
echo date('H:i:s') , " Unprotect a cell" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(\PHPExcel\Style\Protection::PROTECTION_UNPROTECTED);
|
||||
|
||||
// Add a hyperlink to the sheet
|
||||
echo date('H:i:s') , " Add a hyperlink to an external website" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
|
||||
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');
|
||||
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website');
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT);
|
||||
|
||||
echo date('H:i:s') , " Add a hyperlink to another cell on a different worksheet within the workbook" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E27', 'Terms and conditions');
|
||||
$objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1");
|
||||
$objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions');
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(\PHPExcel\Style\Alignment::HORIZONTAL_RIGHT);
|
||||
|
||||
// Add a drawing to the worksheet
|
||||
echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
|
||||
$objDrawing = new \PHPExcel\Worksheet\Drawing();
|
||||
$objDrawing->setName('Logo');
|
||||
$objDrawing->setDescription('Logo');
|
||||
$objDrawing->setPath('./images/officelogo.jpg');
|
||||
$objDrawing->setHeight(36);
|
||||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// Add a drawing to the worksheet
|
||||
echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
|
||||
$objDrawing = new \PHPExcel\Worksheet\Drawing();
|
||||
$objDrawing->setName('Paid');
|
||||
$objDrawing->setDescription('Paid');
|
||||
$objDrawing->setPath('./images/paid.png');
|
||||
$objDrawing->setCoordinates('B15');
|
||||
$objDrawing->setOffsetX(110);
|
||||
$objDrawing->setRotation(25);
|
||||
$objDrawing->getShadow()->setVisible(true);
|
||||
$objDrawing->getShadow()->setDirection(45);
|
||||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// Add a drawing to the worksheet
|
||||
echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
|
||||
$objDrawing = new \PHPExcel\Worksheet\Drawing();
|
||||
$objDrawing->setName('PHPExcel logo');
|
||||
$objDrawing->setDescription('PHPExcel logo');
|
||||
$objDrawing->setPath('./images/phpexcel_logo.gif');
|
||||
$objDrawing->setHeight(36);
|
||||
$objDrawing->setCoordinates('D24');
|
||||
$objDrawing->setOffsetX(10);
|
||||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// Play around with inserting and removing rows and columns
|
||||
echo date('H:i:s') , " Play around with inserting and removing rows and columns" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10);
|
||||
$objPHPExcel->getActiveSheet()->removeRow(6, 10);
|
||||
$objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5);
|
||||
$objPHPExcel->getActiveSheet()->removeColumn('E', 5);
|
||||
|
||||
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
|
||||
echo date('H:i:s') , " Set header/footer" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D');
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') , " Set page orientation and size" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_PORTRAIT);
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel\Worksheet\PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename first worksheet
|
||||
echo date('H:i:s') , " Rename first worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Invoice');
|
||||
|
||||
|
||||
// Create a new worksheet, after the default sheet
|
||||
echo date('H:i:s') , " Create a second Worksheet object" , EOL;
|
||||
$objPHPExcel->createSheet();
|
||||
|
||||
// Llorem ipsum...
|
||||
$sLloremIpsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus eget ante. Sed cursus nunc semper tortor. Aliquam luctus purus non elit. Fusce vel elit commodo sapien dignissim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur accumsan magna sed massa. Nullam bibendum quam ac ipsum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin augue. Praesent malesuada justo sed orci. Pellentesque lacus ligula, sodales quis, ultricies a, ultricies vitae, elit. Sed luctus consectetuer dolor. Vivamus vel sem ut nisi sodales accumsan. Nunc et felis. Suspendisse semper viverra odio. Morbi at odio. Integer a orci a purus venenatis molestie. Nam mattis. Praesent rhoncus, nisi vel mattis auctor, neque nisi faucibus sem, non dapibus elit pede ac nisl. Cras turpis.';
|
||||
|
||||
// Add some data to the second sheet, resembling some different data types
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(1);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Terms and conditions');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', $sLloremIpsum);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', $sLloremIpsum);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', $sLloremIpsum);
|
||||
|
||||
// Set the worksheet tab color
|
||||
echo date('H:i:s') , " Set the worksheet tab color" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF');;
|
||||
|
||||
// Set alignments
|
||||
echo date('H:i:s') , " Set alignments" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getAlignment()->setWrapText(true);
|
||||
|
||||
// Set column widths
|
||||
echo date('H:i:s') , " Set column widths" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
|
||||
|
||||
// Set fonts
|
||||
echo date('H:i:s') , " Set fonts" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara');
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(\PHPExcel\Style\Font::UNDERLINE_SINGLE);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8);
|
||||
|
||||
// Add a drawing to the worksheet
|
||||
echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
|
||||
$objDrawing = new \PHPExcel\Worksheet\Drawing();
|
||||
$objDrawing->setName('Terms and conditions');
|
||||
$objDrawing->setDescription('Terms and conditions');
|
||||
$objDrawing->setPath('./images/termsconditions.jpg');
|
||||
$objDrawing->setCoordinates('B14');
|
||||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') , " Set page orientation and size" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel\Worksheet\PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename second worksheet
|
||||
echo date('H:i:s') , " Rename second worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Terms and conditions');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
include "05featuredemo.inc.php";
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
$cacheMethod = \PHPExcel\CachedObjectStorageFactory::CACHE_TO_SQLITE;
|
||||
if (\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) {
|
||||
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||
} else {
|
||||
echo date('H:i:s') , " Unable to set Cell Caching using " , $cacheMethod , " method, reverting to memory" , EOL;
|
||||
}
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Hide "Phone" and "fax" column
|
||||
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||
|
||||
|
||||
// Set outline levels
|
||||
echo date('H:i:s') , " Set outline levels" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||
->setVisible(false)
|
||||
->setCollapsed(true);
|
||||
|
||||
// Freeze panes
|
||||
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
// Rows to repeat at top
|
||||
echo date('H:i:s') , " Rows to repeat at top" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 5000; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||
->setCellValue('B' . $i, "LName $i")
|
||||
->setCellValue('C' . $i, "PhoneNo $i")
|
||||
->setCellValue('D' . $i, "FaxNo $i")
|
||||
->setCellValue('E' . $i, true);
|
||||
}
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
$cacheMethod = \PHPExcel\CachedObjectStorageFactory::CACHE_TO_SQLITE3;
|
||||
if (\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) {
|
||||
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||
} else {
|
||||
echo date('H:i:s') , " Unable to set Cell Caching using " , $cacheMethod , " method, reverting to memory" , EOL;
|
||||
}
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Hide "Phone" and "fax" column
|
||||
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||
|
||||
|
||||
// Set outline levels
|
||||
echo date('H:i:s') , " Set outline levels" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||
->setVisible(false)
|
||||
->setCollapsed(true);
|
||||
|
||||
// Freeze panes
|
||||
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
// Rows to repeat at top
|
||||
echo date('H:i:s') , " Rows to repeat at top" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 5000; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||
->setCellValue('B' . $i, "LName $i")
|
||||
->setCellValue('C' . $i, "PhoneNo $i")
|
||||
->setCellValue('D' . $i, "FaxNo $i")
|
||||
->setCellValue('E' . $i, true);
|
||||
}
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,128 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
$cacheMethod = \PHPExcel\CachedObjectStorageFactory::CACHE_IN_MEMORY_GZIP;
|
||||
if (!\PHPExcel\Settings::setCacheStorageMethod($cacheMethod)) {
|
||||
die($cacheMethod . " caching method is not available" . EOL);
|
||||
}
|
||||
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Hide "Phone" and "fax" column
|
||||
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||
|
||||
|
||||
// Set outline levels
|
||||
echo date('H:i:s') , " Set outline levels" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||
->setVisible(false)
|
||||
->setCollapsed(true);
|
||||
|
||||
// Freeze panes
|
||||
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
// Rows to repeat at top
|
||||
echo date('H:i:s') , " Rows to repeat at top" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 5000; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||
->setCellValue('B' . $i, "LName $i")
|
||||
->setCellValue('C' . $i, "PhoneNo $i")
|
||||
->setCellValue('D' . $i, "FaxNo $i")
|
||||
->setCellValue('E' . $i, true);
|
||||
}
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
/*
|
||||
After doing some test, I've got these results benchmarked
|
||||
for writing to Excel2007:
|
||||
|
||||
Number of rows Seconds to generate
|
||||
200 3
|
||||
500 4
|
||||
1000 6
|
||||
2000 12
|
||||
4000 36
|
||||
8000 64
|
||||
15000 465
|
||||
*/
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Hide "Phone" and "fax" column
|
||||
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||
|
||||
|
||||
// Set outline levels
|
||||
echo date('H:i:s') , " Set outline levels" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||
->setVisible(false)
|
||||
->setCollapsed(true);
|
||||
|
||||
// Freeze panes
|
||||
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
// Rows to repeat at top
|
||||
echo date('H:i:s') , " Rows to repeat at top" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 5000; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||
->setCellValue('B' . $i, "LName $i")
|
||||
->setCellValue('C' . $i, "PhoneNo $i")
|
||||
->setCellValue('D' . $i, "FaxNo $i")
|
||||
->setCellValue('E' . $i, true);
|
||||
}
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
/*
|
||||
After doing some test, I've got these results benchmarked
|
||||
for writing to Excel2007:
|
||||
|
||||
Number of rows Seconds to generate
|
||||
200 3
|
||||
500 4
|
||||
1000 6
|
||||
2000 12
|
||||
4000 36
|
||||
8000 64
|
||||
15000 465
|
||||
*/
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Hide "Phone" and "fax" column
|
||||
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||
|
||||
|
||||
// Set outline levels
|
||||
echo date('H:i:s') , " Set outline levels" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||
->setVisible(false)
|
||||
->setCollapsed(true);
|
||||
|
||||
// Freeze panes
|
||||
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
// Rows to repeat at top
|
||||
echo date('H:i:s') , " Rows to repeat at top" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 5000; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||
->setCellValue('B' . $i, "LName $i")
|
||||
->setCellValue('C' . $i, "PhoneNo $i")
|
||||
->setCellValue('D' . $i, "FaxNo $i")
|
||||
->setCellValue('E' . $i, true);
|
||||
}
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
if (!file_exists("05featuredemo.xlsx")) {
|
||||
exit("Please run 05featuredemo.php first." . EOL);
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objPHPExcel = \PHPExcel\IOFactory::load("05featuredemo.xlsx");
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
if (!file_exists("05featuredemo.xlsx")) {
|
||||
exit("Please run 05featuredemo.php first." . EOL);
|
||||
}
|
||||
|
||||
// Use PCLZip rather than ZipArchive to read the Excel2007 OfficeOpenXML file
|
||||
\PHPExcel\Settings::setZipClass(\PHPExcel\Settings::PCLZIP);
|
||||
|
||||
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objPHPExcel = \PHPExcel\IOFactory::load("05featuredemo.xlsx");
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,189 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet, representing sales data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Description')
|
||||
->setCellValue('B1', 'Amount');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Paycheck received')
|
||||
->setCellValue('B2', 100);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Cup of coffee bought')
|
||||
->setCellValue('B3', -1.5);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Cup of coffee bought')
|
||||
->setCellValue('B4', -1.5);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Cup of tea bought')
|
||||
->setCellValue('B5', -1.2);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Found some money')
|
||||
->setCellValue('B6', 8);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Total:')
|
||||
->setCellValue('B7', '=SUM(B2:B6)');
|
||||
|
||||
|
||||
// Set column widths
|
||||
echo date('H:i:s') , " Set column widths" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
|
||||
|
||||
|
||||
// Add conditional formatting
|
||||
echo date('H:i:s') , " Add conditional formatting" , EOL;
|
||||
$objConditional1 = new \PHPExcel\Style\Conditional();
|
||||
$objConditional1->setConditionType(\PHPExcel\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PHPExcel\Style\Conditional::OPERATOR_BETWEEN)
|
||||
->addCondition('200')
|
||||
->addCondition('400');
|
||||
$objConditional1->getStyle()->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_YELLOW);
|
||||
$objConditional1->getStyle()->getFont()->setBold(true);
|
||||
$objConditional1->getStyle()->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
$objConditional2 = new \PHPExcel\Style\Conditional();
|
||||
$objConditional2->setConditionType(\PHPExcel\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PHPExcel\Style\Conditional::OPERATOR_LESSTHAN)
|
||||
->addCondition('0');
|
||||
$objConditional2->getStyle()->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_RED);
|
||||
$objConditional2->getStyle()->getFont()->setItalic(true);
|
||||
$objConditional2->getStyle()->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
$objConditional3 = new \PHPExcel\Style\Conditional();
|
||||
$objConditional3->setConditionType(\PHPExcel\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PHPExcel\Style\Conditional::OPERATOR_GREATERTHANOREQUAL)
|
||||
->addCondition('0');
|
||||
$objConditional3->getStyle()->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_GREEN);
|
||||
$objConditional3->getStyle()->getFont()->setItalic(true);
|
||||
$objConditional3->getStyle()->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles();
|
||||
array_push($conditionalStyles, $objConditional1);
|
||||
array_push($conditionalStyles, $objConditional2);
|
||||
array_push($conditionalStyles, $objConditional3);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
|
||||
|
||||
|
||||
// duplicate the conditional styles across a range of cells
|
||||
echo date('H:i:s') , " Duplicate the conditional formatting across a range of cells" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
|
||||
$objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles(),
|
||||
'B3:B7'
|
||||
);
|
||||
|
||||
|
||||
// Set fonts
|
||||
echo date('H:i:s') , " Set fonts" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:B1')->getFont()->setBold(true);
|
||||
//$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A7:B7')->getFont()->setBold(true);
|
||||
//$objPHPExcel->getActiveSheet()->getStyle('B7')->getFont()->setBold(true);
|
||||
|
||||
|
||||
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
|
||||
echo date('H:i:s') , " Set header/footer" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BPersonal cash register&RPrinted on &D');
|
||||
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||
|
||||
|
||||
// Set page orientation and size
|
||||
echo date('H:i:s') , " Set page orientation and size" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_PORTRAIT);
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel\Worksheet\PageSetup::PAPERSIZE_A4);
|
||||
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Invoice');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet, representing sales data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('A1', '-0.5')
|
||||
->setCellValue('A2', '-0.25')
|
||||
->setCellValue('A3', '0.0')
|
||||
->setCellValue('A4', '0.25')
|
||||
->setCellValue('A5', '0.5')
|
||||
->setCellValue('A6', '0.75')
|
||||
->setCellValue('A7', '1.0')
|
||||
->setCellValue('A8', '1.25')
|
||||
;
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:A8')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(
|
||||
\PHPExcel\Style\NumberFormat::FORMAT_PERCENTAGE_00
|
||||
);
|
||||
|
||||
|
||||
// Add conditional formatting
|
||||
echo date('H:i:s') , " Add conditional formatting" , EOL;
|
||||
$objConditional1 = new \PHPExcel\Style\Conditional();
|
||||
$objConditional1->setConditionType(\PHPExcel\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PHPExcel\Style\Conditional::OPERATOR_LESSTHAN)
|
||||
->addCondition('0');
|
||||
$objConditional1->getStyle()->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_RED);
|
||||
|
||||
$objConditional3 = new \PHPExcel\Style\Conditional();
|
||||
$objConditional3->setConditionType(\PHPExcel\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PHPExcel\Style\Conditional::OPERATOR_GREATERTHANOREQUAL)
|
||||
->addCondition('1');
|
||||
$objConditional3->getStyle()->getFont()->getColor()->setARGB(\PHPExcel\Style\Color::COLOR_GREEN);
|
||||
|
||||
$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('A1')->getConditionalStyles();
|
||||
array_push($conditionalStyles, $objConditional1);
|
||||
array_push($conditionalStyles, $objConditional3);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles);
|
||||
|
||||
|
||||
// duplicate the conditional styles across a range of cells
|
||||
echo date('H:i:s') , " Duplicate the conditional formatting across a range of cells" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')->getConditionalStyles(),
|
||||
'A2:A8'
|
||||
);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data and page breaks" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname")
|
||||
->setCellValue('B1', "Lastname")
|
||||
->setCellValue('C1', "Phone")
|
||||
->setCellValue('D1', "Fax")
|
||||
->setCellValue('E1', "Is Client ?");
|
||||
|
||||
|
||||
// Add data
|
||||
for ($i = 2; $i <= 50; $i++) {
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i, "LName $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i, "PhoneNo $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i, "FaxNo $i");
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E' . $i, true);
|
||||
|
||||
// Add page breaks every 10 rows
|
||||
if ($i % 10 == 0) {
|
||||
// Add a page break
|
||||
$objPHPExcel->getActiveSheet()->setBreak( 'A' . $i, \PHPExcel\Worksheet::BREAK_ROW );
|
||||
}
|
||||
}
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Printing Options');
|
||||
|
||||
// Set print headers
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getHeaderFooter()->setOddHeader('&C&24&K0000FF&B&U&A');
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getHeaderFooter()->setEvenHeader('&C&24&K0000FF&B&U&A');
|
||||
|
||||
// Set print footers
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getHeaderFooter()->setOddFooter('&R&D &T&C&F&LPage &P / &N');
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getHeaderFooter()->setEvenFooter('&L&D &T&C&F&RPage &P / &N');
|
||||
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,221 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s').' Create new PHPExcel object'.EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s').' Set document properties'.EOL;
|
||||
$objPHPExcel->getProperties()->setCreator('Maarten Balliauw')
|
||||
->setLastModifiedBy('Maarten Balliauw')
|
||||
->setTitle('PHPExcel Test Document')
|
||||
->setSubject('PHPExcel Test Document')
|
||||
->setDescription('Test document for PHPExcel, generated using PHP classes.')
|
||||
->setKeywords('office PHPExcel php')
|
||||
->setCategory('Test result file');
|
||||
|
||||
// Create the worksheet
|
||||
echo date('H:i:s').' Add data'.EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Financial Year')
|
||||
->setCellValue('B1', 'Financial Period')
|
||||
->setCellValue('C1', 'Country')
|
||||
->setCellValue('D1', 'Date')
|
||||
->setCellValue('E1', 'Sales Value')
|
||||
->setCellValue('F1', 'Expenditure')
|
||||
;
|
||||
$startYear = $endYear = $currentYear = date('Y');
|
||||
$startYear--;
|
||||
$endYear++;
|
||||
|
||||
$years = range($startYear,$endYear);
|
||||
$periods = range(1,12);
|
||||
$countries = array( 'United States', 'UK', 'France', 'Germany',
|
||||
'Italy', 'Spain', 'Portugal', 'Japan'
|
||||
);
|
||||
|
||||
$row = 2;
|
||||
foreach($years as $year) {
|
||||
foreach($periods as $period) {
|
||||
foreach($countries as $country) {
|
||||
$endDays = date('t',mktime(0,0,0,$period,1,$year));
|
||||
for($i = 1; $i <= $endDays; ++$i) {
|
||||
$eDate = \PHPExcel\Shared\Date::formattedPHPToExcel(
|
||||
$year,
|
||||
$period,
|
||||
$i
|
||||
);
|
||||
$value = rand(500,1000) * (1 + rand(-0.25,+0.25));
|
||||
$salesValue = $invoiceValue = NULL;
|
||||
$incomeOrExpenditure = rand(-1,1);
|
||||
if ($incomeOrExpenditure == -1) {
|
||||
$expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25));
|
||||
$income = NULL;
|
||||
} elseif ($incomeOrExpenditure == 1) {
|
||||
$expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25));
|
||||
$income = rand(500,1000) * (1 + rand(-0.25,+0.25));;
|
||||
} else {
|
||||
$expenditure = NULL;
|
||||
$income = rand(500,1000) * (1 + rand(-0.25,+0.25));;
|
||||
}
|
||||
$dataArray = array( $year,
|
||||
$period,
|
||||
$country,
|
||||
$eDate,
|
||||
$income,
|
||||
$expenditure,
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$row--;
|
||||
|
||||
|
||||
// Set styling
|
||||
echo date('H:i:s').' Set styling'.EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(TRUE);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(12.5);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(10.5);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D2:D'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E2:F'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(14);
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
|
||||
// Set autofilter range
|
||||
echo date('H:i:s').' Set autofilter range'.EOL;
|
||||
// Always include the complete filter range!
|
||||
// Excel does support setting only the caption
|
||||
// row, but that's not a best practise...
|
||||
$objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->calculateWorksheetDimension());
|
||||
|
||||
// Set active filters
|
||||
$autoFilter = $objPHPExcel->getActiveSheet()->getAutoFilter();
|
||||
echo date('H:i:s').' Set active filters'.EOL;
|
||||
// Filter the Country column on a filter value of countries beginning with the letter U (or Japan)
|
||||
// We use * as a wildcard, so specify as U* and using a wildcard requires customFilter
|
||||
$autoFilter->getColumn('C')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'u*'
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
$autoFilter->getColumn('C')
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'japan'
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
// Filter the Date column on a filter value of the first day of every period of the current year
|
||||
// We us a dateGroup ruletype for this, although it is still a standard filter
|
||||
foreach($periods as $period) {
|
||||
$endDate = date('t',mktime(0,0,0,$period,1,$currentYear));
|
||||
|
||||
$autoFilter->getColumn('D')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
array(
|
||||
'year' => $currentYear,
|
||||
'month' => $period,
|
||||
'day' => $endDate
|
||||
)
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP);
|
||||
}
|
||||
// Display only sales values that are blank
|
||||
// Standard filter, operator equals, and value of NULL
|
||||
$autoFilter->getColumn('E')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
''
|
||||
);
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s').' Done writing files'.EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,212 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s').' Create new PHPExcel object'.EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s').' Set document properties'.EOL;
|
||||
$objPHPExcel->getProperties()->setCreator('Maarten Balliauw')
|
||||
->setLastModifiedBy('Maarten Balliauw')
|
||||
->setTitle('PHPExcel Test Document')
|
||||
->setSubject('PHPExcel Test Document')
|
||||
->setDescription('Test document for PHPExcel, generated using PHP classes.')
|
||||
->setKeywords('office PHPExcel php')
|
||||
->setCategory('Test result file');
|
||||
|
||||
// Create the worksheet
|
||||
echo date('H:i:s').' Add data'.EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Financial Year')
|
||||
->setCellValue('B1', 'Financial Period')
|
||||
->setCellValue('C1', 'Country')
|
||||
->setCellValue('D1', 'Date')
|
||||
->setCellValue('E1', 'Sales Value')
|
||||
->setCellValue('F1', 'Expenditure');
|
||||
$startYear = $endYear = $currentYear = date('Y');
|
||||
$startYear--;
|
||||
$endYear++;
|
||||
|
||||
$years = range($startYear,$endYear);
|
||||
$periods = range(1,12);
|
||||
$countries = array( 'United States', 'UK', 'France', 'Germany',
|
||||
'Italy', 'Spain', 'Portugal', 'Japan'
|
||||
);
|
||||
|
||||
$row = 2;
|
||||
foreach($years as $year) {
|
||||
foreach($periods as $period) {
|
||||
foreach($countries as $country) {
|
||||
$endDays = date('t',mktime(0,0,0,$period,1,$year));
|
||||
for($i = 1; $i <= $endDays; ++$i) {
|
||||
$eDate = \PHPExcel\Shared\Date::formattedPHPToExcel(
|
||||
$year,
|
||||
$period,
|
||||
$i
|
||||
);
|
||||
$value = rand(500,1000) * (1 + rand(-0.25,+0.25));
|
||||
$salesValue = $invoiceValue = NULL;
|
||||
$incomeOrExpenditure = rand(-1,1);
|
||||
if ($incomeOrExpenditure == -1) {
|
||||
$expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25));
|
||||
$income = NULL;
|
||||
} elseif ($incomeOrExpenditure == 1) {
|
||||
$expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25));
|
||||
$income = rand(500,1000) * (1 + rand(-0.25,+0.25));;
|
||||
} else {
|
||||
$expenditure = NULL;
|
||||
$income = rand(500,1000) * (1 + rand(-0.25,+0.25));;
|
||||
}
|
||||
$dataArray = array( $year,
|
||||
$period,
|
||||
$country,
|
||||
$eDate,
|
||||
$income,
|
||||
$expenditure,
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$row--;
|
||||
|
||||
|
||||
// Set styling
|
||||
echo date('H:i:s').' Set styling'.EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(TRUE);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(12.5);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(10.5);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D2:D'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E2:F'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(14);
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
|
||||
// Set autofilter range
|
||||
echo date('H:i:s').' Set autofilter range'.EOL;
|
||||
// Always include the complete filter range!
|
||||
// Excel does support setting only the caption
|
||||
// row, but that's not a best practise...
|
||||
$objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->calculateWorksheetDimension());
|
||||
|
||||
// Set active filters
|
||||
$autoFilter = $objPHPExcel->getActiveSheet()->getAutoFilter();
|
||||
echo date('H:i:s').' Set active filters'.EOL;
|
||||
// Filter the Country column on a filter value of Germany
|
||||
// As it's just a simple value filter, we can use FILTERTYPE_FILTER
|
||||
$autoFilter->getColumn('C')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'Germany'
|
||||
);
|
||||
// Filter the Date column on a filter value of the year to date
|
||||
$autoFilter->getColumn('D')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
NULL,
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
|
||||
// Display only sales values that are between 400 and 600
|
||||
$autoFilter->getColumn('E')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL,
|
||||
400
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
$autoFilter->getColumn('E')
|
||||
->setJoin(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL,
|
||||
600
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s').' Done writing files'.EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,198 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s').' Create new PHPExcel object'.EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s').' Set document properties'.EOL;
|
||||
$objPHPExcel->getProperties()->setCreator('Maarten Balliauw')
|
||||
->setLastModifiedBy('Maarten Balliauw')
|
||||
->setTitle('PHPExcel Test Document')
|
||||
->setSubject('PHPExcel Test Document')
|
||||
->setDescription('Test document for PHPExcel, generated using PHP classes.')
|
||||
->setKeywords('office PHPExcel php')
|
||||
->setCategory('Test result file');
|
||||
|
||||
// Create the worksheet
|
||||
echo date('H:i:s').' Add data'.EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Financial Year')
|
||||
->setCellValue('B1', 'Financial Period')
|
||||
->setCellValue('C1', 'Country')
|
||||
->setCellValue('D1', 'Date')
|
||||
->setCellValue('E1', 'Sales Value')
|
||||
->setCellValue('F1', 'Expenditure')
|
||||
;
|
||||
$startYear = $endYear = $currentYear = date('Y');
|
||||
$startYear--;
|
||||
$endYear++;
|
||||
|
||||
$years = range($startYear,$endYear);
|
||||
$periods = range(1,12);
|
||||
$countries = array( 'United States', 'UK', 'France', 'Germany',
|
||||
'Italy', 'Spain', 'Portugal', 'Japan'
|
||||
);
|
||||
|
||||
$row = 2;
|
||||
foreach($years as $year) {
|
||||
foreach($periods as $period) {
|
||||
foreach($countries as $country) {
|
||||
$endDays = date('t',mktime(0,0,0,$period,1,$year));
|
||||
for($i = 1; $i <= $endDays; ++$i) {
|
||||
$eDate = \PHPExcel\Shared\Date::formattedPHPToExcel(
|
||||
$year,
|
||||
$period,
|
||||
$i
|
||||
);
|
||||
$value = rand(500,1000) * (1 + rand(-0.25,+0.25));
|
||||
$salesValue = $invoiceValue = NULL;
|
||||
$incomeOrExpenditure = rand(-1,1);
|
||||
if ($incomeOrExpenditure == -1) {
|
||||
$expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25));
|
||||
$income = NULL;
|
||||
} elseif ($incomeOrExpenditure == 1) {
|
||||
$expenditure = rand(-500,-1000) * (1 + rand(-0.25,+0.25));
|
||||
$income = rand(500,1000) * (1 + rand(-0.25,+0.25));;
|
||||
} else {
|
||||
$expenditure = NULL;
|
||||
$income = rand(500,1000) * (1 + rand(-0.25,+0.25));;
|
||||
}
|
||||
$dataArray = array( $year,
|
||||
$period,
|
||||
$country,
|
||||
$eDate,
|
||||
$income,
|
||||
$expenditure,
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A'.$row++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$row--;
|
||||
|
||||
|
||||
// Set styling
|
||||
echo date('H:i:s').' Set styling'.EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(TRUE);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(12.5);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(10.5);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('D2:D'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('E2:F'.$row)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(14);
|
||||
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
||||
|
||||
// Set autofilter range
|
||||
echo date('H:i:s').' Set autofilter range'.EOL;
|
||||
// Always include the complete filter range!
|
||||
// Excel does support setting only the caption
|
||||
// row, but that's not a best practise...
|
||||
$objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->calculateWorksheetDimension());
|
||||
|
||||
// Set active filters
|
||||
$autoFilter = $objPHPExcel->getActiveSheet()->getAutoFilter();
|
||||
echo date('H:i:s').' Set active filters'.EOL;
|
||||
// Filter the Country column on a filter value of countries beginning with the letter U (or Japan)
|
||||
// We use * as a wildcard, so specify as U* and using a wildcard requires customFilter
|
||||
$autoFilter->getColumn('C')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'u*'
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
$autoFilter->getColumn('C')
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'japan'
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
// Filter the Date column on a filter value of the first day of every period of the current year
|
||||
// We us a dateGroup ruletype for this, although it is still a standard filter
|
||||
foreach($periods as $period) {
|
||||
$endDate = date('t',mktime(0,0,0,$period,1,$currentYear));
|
||||
|
||||
$autoFilter->getColumn('D')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
array(
|
||||
'year' => $currentYear,
|
||||
'month' => $period,
|
||||
'day' => $endDate
|
||||
)
|
||||
)
|
||||
->setRuleType(\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP);
|
||||
}
|
||||
// Display only sales values that are blank
|
||||
// Standard filter, operator equals, and value of NULL
|
||||
$autoFilter->getColumn('E')
|
||||
->setFilterType(\PHPExcel\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PHPExcel\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
''
|
||||
);
|
||||
|
||||
// Execute filtering
|
||||
echo date('H:i:s').' Execute filtering'.EOL;
|
||||
$autoFilter->showHideRows();
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Display Results of filtering
|
||||
echo date('H:i:s').' Display filtered rows'.EOL;
|
||||
foreach ($objPHPExcel->getActiveSheet()->getRowIterator() as $row) {
|
||||
if ($objPHPExcel->getActiveSheet()->getRowDimension($row->getRowIndex())->getVisible()) {
|
||||
echo ' Row number - ' , $row->getRowIndex() , ' ';
|
||||
echo $objPHPExcel->getActiveSheet()->getCell('C'.$row->getRowIndex())->getValue(), ' ';
|
||||
echo $objPHPExcel->getActiveSheet()->getCell('D'.$row->getRowIndex())->getFormattedValue(), ' ';
|
||||
echo EOL;
|
||||
}
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s').' Create new PHPExcel object'.EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s').' Set document properties'.EOL;
|
||||
$objPHPExcel->getProperties()->setCreator('Maarten Balliauw')
|
||||
->setLastModifiedBy('Maarten Balliauw')
|
||||
->setTitle('PHPExcel Test Document')
|
||||
->setSubject('PHPExcel Test Document')
|
||||
->setDescription('Test document for PHPExcel, generated using PHP classes.')
|
||||
->setKeywords('office PHPExcel php')
|
||||
->setCategory('Test result file');
|
||||
|
||||
// Create the worksheet
|
||||
echo date('H:i:s').' Add data'.EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Year')
|
||||
->setCellValue('B1', 'Quarter')
|
||||
->setCellValue('C1', 'Country')
|
||||
->setCellValue('D1', 'Sales');
|
||||
|
||||
$dataArray = array(array('2010', 'Q1', 'United States', 790),
|
||||
array('2010', 'Q2', 'United States', 730),
|
||||
array('2010', 'Q3', 'United States', 860),
|
||||
array('2010', 'Q4', 'United States', 850),
|
||||
array('2011', 'Q1', 'United States', 800),
|
||||
array('2011', 'Q2', 'United States', 700),
|
||||
array('2011', 'Q3', 'United States', 900),
|
||||
array('2011', 'Q4', 'United States', 950),
|
||||
array('2010', 'Q1', 'Belgium', 380),
|
||||
array('2010', 'Q2', 'Belgium', 390),
|
||||
array('2010', 'Q3', 'Belgium', 420),
|
||||
array('2010', 'Q4', 'Belgium', 460),
|
||||
array('2011', 'Q1', 'Belgium', 400),
|
||||
array('2011', 'Q2', 'Belgium', 350),
|
||||
array('2011', 'Q3', 'Belgium', 450),
|
||||
array('2011', 'Q4', 'Belgium', 500),
|
||||
array('2010', 'Q1', 'UK', 690),
|
||||
array('2010', 'Q2', 'UK', 610),
|
||||
array('2010', 'Q3', 'UK', 620),
|
||||
array('2010', 'Q4', 'UK', 600),
|
||||
array('2011', 'Q1', 'UK', 720),
|
||||
array('2011', 'Q2', 'UK', 650),
|
||||
array('2011', 'Q3', 'UK', 580),
|
||||
array('2011', 'Q4', 'UK', 510),
|
||||
array('2010', 'Q1', 'France', 510),
|
||||
array('2010', 'Q2', 'France', 490),
|
||||
array('2010', 'Q3', 'France', 460),
|
||||
array('2010', 'Q4', 'France', 590),
|
||||
array('2011', 'Q1', 'France', 620),
|
||||
array('2011', 'Q2', 'France', 650),
|
||||
array('2011', 'Q3', 'France', 415),
|
||||
array('2011', 'Q4', 'France', 570),
|
||||
array('2010', 'Q1', 'Germany', 720),
|
||||
array('2010', 'Q2', 'Germany', 680),
|
||||
array('2010', 'Q3', 'Germany', 640),
|
||||
array('2010', 'Q4', 'Germany', 660),
|
||||
array('2011', 'Q1', 'Germany', 680),
|
||||
array('2011', 'Q2', 'Germany', 620),
|
||||
array('2011', 'Q3', 'Germany', 710),
|
||||
array('2011', 'Q4', 'Germany', 690),
|
||||
array('2010', 'Q1', 'Spain', 510),
|
||||
array('2010', 'Q2', 'Spain', 490),
|
||||
array('2010', 'Q3', 'Spain', 470),
|
||||
array('2010', 'Q4', 'Spain', 420),
|
||||
array('2011', 'Q1', 'Spain', 460),
|
||||
array('2011', 'Q2', 'Spain', 390),
|
||||
array('2011', 'Q3', 'Spain', 430),
|
||||
array('2011', 'Q4', 'Spain', 415),
|
||||
array('2010', 'Q1', 'Italy', 440),
|
||||
array('2010', 'Q2', 'Italy', 410),
|
||||
array('2010', 'Q3', 'Italy', 420),
|
||||
array('2010', 'Q4', 'Italy', 450),
|
||||
array('2011', 'Q1', 'Italy', 430),
|
||||
array('2011', 'Q2', 'Italy', 370),
|
||||
array('2011', 'Q3', 'Italy', 350),
|
||||
array('2011', 'Q4', 'Italy', 335),
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->fromArray($dataArray, NULL, 'A2');
|
||||
|
||||
// Set title row bold
|
||||
echo date('H:i:s').' Set title row bold'.EOL;
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:D1')->getFont()->setBold(true);
|
||||
|
||||
// Set autofilter
|
||||
echo date('H:i:s').' Set autofilter'.EOL;
|
||||
// Always include the complete filter range!
|
||||
// Excel does support setting only the caption
|
||||
// row, but that's not a best practise...
|
||||
$objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->calculateWorksheetDimension());
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s').' Done writing files'.EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set document security
|
||||
echo date('H:i:s') , " Set document security" , EOL;
|
||||
$objPHPExcel->getSecurity()->setLockWindows(true);
|
||||
$objPHPExcel->getSecurity()->setLockStructure(true);
|
||||
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
||||
|
||||
|
||||
// Set sheet security
|
||||
echo date('H:i:s') , " Set sheet security" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setPassword('PHPExcel');
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setInsertRows(true);
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set document security
|
||||
echo date('H:i:s') , " Set document security" , EOL;
|
||||
$objPHPExcel->getSecurity()->setLockWindows(true);
|
||||
$objPHPExcel->getSecurity()->setLockStructure(true);
|
||||
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
|
||||
|
||||
|
||||
// Set sheet security
|
||||
echo date('H:i:s') , " Set sheet security" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setPassword('PHPExcel');
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // This should be enabled in order to enable any of the following!
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setInsertRows(true);
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,107 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Mark Baker")
|
||||
->setLastModifiedBy("Mark Baker")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Crouching');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Tiger');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Hidden');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Dragon');
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Set document security
|
||||
echo date('H:i:s') , " Set cell protection" , EOL;
|
||||
|
||||
|
||||
// Set sheet security
|
||||
echo date('H:i:s') , " Set sheet security" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getStyle('A2:B2')
|
||||
->getProtection()->setLocked(
|
||||
\PHPExcel\Style\Protection::PROTECTION_UNPROTECTED
|
||||
);
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,235 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
mt_srand(1234567890);
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// List functions
|
||||
echo date('H:i:s') , " List implemented functions" , EOL;
|
||||
$objCalc = \PHPExcel\Calculation::getInstance();
|
||||
print_r($objCalc->listFunctionNames());
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
echo date('H:i:s') , " Add some data and formulas" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:')
|
||||
->setCellValue('A15', 'Sum:')
|
||||
->setCellValue('A16', 'Max:')
|
||||
->setCellValue('A17', 'Min:')
|
||||
->setCellValue('A18', 'Average:')
|
||||
->setCellValue('A19', 'Median:')
|
||||
->setCellValue('A20', 'Mode:');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'CountA:')
|
||||
->setCellValue('A23', 'MaxA:')
|
||||
->setCellValue('A24', 'MinA:');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'StDev:')
|
||||
->setCellValue('A27', 'StDevA:')
|
||||
->setCellValue('A28', 'StDevP:')
|
||||
->setCellValue('A29', 'StDevPA:');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A31', 'DevSq:')
|
||||
->setCellValue('A32', 'Var:')
|
||||
->setCellValue('A33', 'VarA:')
|
||||
->setCellValue('A34', 'VarP:')
|
||||
->setCellValue('A35', 'VarPA:');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A37', 'Date:');
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1')
|
||||
->setCellValue('B2', 2)
|
||||
->setCellValue('B3', 8)
|
||||
->setCellValue('B4', 10)
|
||||
->setCellValue('B5', True)
|
||||
->setCellValue('B6', False)
|
||||
->setCellValue('B7', 'Text String')
|
||||
->setCellValue('B9', '22')
|
||||
->setCellValue('B10', 4)
|
||||
->setCellValue('B11', 6)
|
||||
->setCellValue('B12', 12);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)')
|
||||
->setCellValue('B15', '=SUM(B2:B12)')
|
||||
->setCellValue('B16', '=MAX(B2:B12)')
|
||||
->setCellValue('B17', '=MIN(B2:B12)')
|
||||
->setCellValue('B18', '=AVERAGE(B2:B12)')
|
||||
->setCellValue('B19', '=MEDIAN(B2:B12)')
|
||||
->setCellValue('B20', '=MODE(B2:B12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B22', '=COUNTA(B2:B12)')
|
||||
->setCellValue('B23', '=MAXA(B2:B12)')
|
||||
->setCellValue('B24', '=MINA(B2:B12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B26', '=STDEV(B2:B12)')
|
||||
->setCellValue('B27', '=STDEVA(B2:B12)')
|
||||
->setCellValue('B28', '=STDEVP(B2:B12)')
|
||||
->setCellValue('B29', '=STDEVPA(B2:B12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B31', '=DEVSQ(B2:B12)')
|
||||
->setCellValue('B32', '=VAR(B2:B12)')
|
||||
->setCellValue('B33', '=VARA(B2:B12)')
|
||||
->setCellValue('B34', '=VARP(B2:B12)')
|
||||
->setCellValue('B35', '=VARPA(B2:B12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B37', '=DATE(2007, 12, 21)')
|
||||
->setCellValue('B38', '=DATEDIF( DATE(2007, 12, 21), DATE(2007, 12, 22), "D" )')
|
||||
->setCellValue('B39', '=DATEVALUE("01-Feb-2006 10:06 AM")')
|
||||
->setCellValue('B40', '=DAY( DATE(2006, 1, 2) )')
|
||||
->setCellValue('B41', '=DAYS360( DATE(2002, 2, 3), DATE(2005, 5, 31) )');
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2')
|
||||
->setCellValue('C2', 1)
|
||||
->setCellValue('C3', 2)
|
||||
->setCellValue('C4', 2)
|
||||
->setCellValue('C5', 3)
|
||||
->setCellValue('C6', 3)
|
||||
->setCellValue('C7', 3)
|
||||
->setCellValue('C8', '0')
|
||||
->setCellValue('C9', 4)
|
||||
->setCellValue('C10', 4)
|
||||
->setCellValue('C11', 4)
|
||||
->setCellValue('C12', 4);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)')
|
||||
->setCellValue('C15', '=SUM(C2:C12)')
|
||||
->setCellValue('C16', '=MAX(C2:C12)')
|
||||
->setCellValue('C17', '=MIN(C2:C12)')
|
||||
->setCellValue('C18', '=AVERAGE(C2:C12)')
|
||||
->setCellValue('C19', '=MEDIAN(C2:C12)')
|
||||
->setCellValue('C20', '=MODE(C2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C22', '=COUNTA(C2:C12)')
|
||||
->setCellValue('C23', '=MAXA(C2:C12)')
|
||||
->setCellValue('C24', '=MINA(C2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C26', '=STDEV(C2:C12)')
|
||||
->setCellValue('C27', '=STDEVA(C2:C12)')
|
||||
->setCellValue('C28', '=STDEVP(C2:C12)')
|
||||
->setCellValue('C29', '=STDEVPA(C2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C31', '=DEVSQ(C2:C12)')
|
||||
->setCellValue('C32', '=VAR(C2:C12)')
|
||||
->setCellValue('C33', '=VARA(C2:C12)')
|
||||
->setCellValue('C34', '=VARP(C2:C12)')
|
||||
->setCellValue('C35', '=VARPA(C2:C12)');
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3')
|
||||
->setCellValue('D2', 2)
|
||||
->setCellValue('D3', 3)
|
||||
->setCellValue('D4', 4);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D14', '=((D2 * D3) + D4) & " should be 10"');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E12', 'Other functions')
|
||||
->setCellValue('E14', '=PI()')
|
||||
->setCellValue('E15', '=RAND()')
|
||||
->setCellValue('E16', '=RANDBETWEEN(5, 10)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E17', 'Count of both ranges:')
|
||||
->setCellValue('F17', '=COUNT(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E18', 'Total of both ranges:')
|
||||
->setCellValue('F18', '=SUM(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E19', 'Maximum of both ranges:')
|
||||
->setCellValue('F19', '=MAX(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E20', 'Minimum of both ranges:')
|
||||
->setCellValue('F20', '=MIN(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E21', 'Average of both ranges:')
|
||||
->setCellValue('F21', '=AVERAGE(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E22', 'Median of both ranges:')
|
||||
->setCellValue('F22', '=MEDIAN(B2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
|
||||
->setCellValue('F23', '=MODE(B2:C12)');
|
||||
|
||||
|
||||
// Calculated data
|
||||
echo date('H:i:s') , " Calculated data" , EOL;
|
||||
for ($col = 'B'; $col != 'G'; ++$col) {
|
||||
for($row = 14; $row <= 41; ++$row) {
|
||||
if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) &&
|
||||
($formula[0] == '=')) {
|
||||
echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' ,
|
||||
$objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
|
||||
//
|
||||
// If we set Pre Calculated Formulas to true then PHPExcel will calculate all formulae in the
|
||||
// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
|
||||
// using functions or features (such as array formulae) that aren't yet supported by the calculation engine
|
||||
// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to
|
||||
// open the file) will need to recalculate values itself to guarantee that the correct results are available.
|
||||
//
|
||||
//$objWriter->setPreCalculateFormulas(true);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (C) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
echo date('H:i:s') , " Add some data and formulas" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', '=B1')
|
||||
->setCellValue('A2', '=B2+1')
|
||||
->setCellValue('B1', '=A1+1')
|
||||
->setCellValue('B2', '=A2');
|
||||
|
||||
\PHPExcel\Calculation::getInstance($objPHPExcel)->cyclicFormulaCount = 100;
|
||||
|
||||
// Calculated data
|
||||
echo date('H:i:s') , " Calculated data" , EOL;
|
||||
for($row = 1; $row <= 2; ++$row) {
|
||||
for ($col = 'A'; $col != 'C'; ++$col) {
|
||||
if ((!is_null($formula = $objPHPExcel->getActiveSheet()->getCell($col.$row)->getValue())) &&
|
||||
($formula[0] == '=')) {
|
||||
echo 'Value of ' , $col , $row , ' [' , $formula , ']: ' ,
|
||||
$objPHPExcel->getActiveSheet()->getCell($col.$row)->getCalculatedValue() . EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
|
||||
//
|
||||
// If we set Pre Calculated Formulas to true then PHPExcel will calculate all formulae in the
|
||||
// workbook before saving. This adds time and memory overhead, and can cause some problems with formulae
|
||||
// using functions or features (such as array formulae) that aren't yet supported by the calculation engine
|
||||
// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to
|
||||
// open the file) will need to recalculate values itself to guarantee that the correct results are available.
|
||||
//
|
||||
//$objWriter->setPreCalculateFormulas(true);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
include "05featuredemo.inc.php";
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,142 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...")
|
||||
->setCellValue('A3', "Number:")
|
||||
->setCellValue('B3', "10")
|
||||
->setCellValue('A5', "List:")
|
||||
->setCellValue('B5', "Item A")
|
||||
->setCellValue('A7', "List #2:")
|
||||
->setCellValue('B7', "Item #2")
|
||||
->setCellValue('D2', "Item #1")
|
||||
->setCellValue('D3', "Item #2")
|
||||
->setCellValue('D4', "Item #3")
|
||||
->setCellValue('D5', "Item #4")
|
||||
->setCellValue('D6', "Item #5")
|
||||
;
|
||||
|
||||
|
||||
// Set data validation
|
||||
echo date('H:i:s') , " Set data validation" , EOL;
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
|
||||
$objValidation->setType( \PHPExcel\Cell\DataValidation::TYPE_WHOLE );
|
||||
$objValidation->setErrorStyle( \PHPExcel\Cell\DataValidation::STYLE_STOP );
|
||||
$objValidation->setAllowBlank(true);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Only numbers between 10 and 20 are allowed!');
|
||||
$objValidation->setPromptTitle('Allowed input');
|
||||
$objValidation->setPrompt('Only numbers between 10 and 20 are allowed.');
|
||||
$objValidation->setFormula1(10);
|
||||
$objValidation->setFormula2(20);
|
||||
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B5')->getDataValidation();
|
||||
$objValidation->setType( \PHPExcel\Cell\DataValidation::TYPE_LIST );
|
||||
$objValidation->setErrorStyle( \PHPExcel\Cell\DataValidation::STYLE_INFORMATION );
|
||||
$objValidation->setAllowBlank(false);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setShowDropDown(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Value is not in list.');
|
||||
$objValidation->setPromptTitle('Pick from list');
|
||||
$objValidation->setPrompt('Please pick a value from the drop-down list.');
|
||||
$objValidation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the list items between " and " !!!
|
||||
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B7')->getDataValidation();
|
||||
$objValidation->setType( \PHPExcel\Cell\DataValidation::TYPE_LIST );
|
||||
$objValidation->setErrorStyle( \PHPExcel\Cell\DataValidation::STYLE_INFORMATION );
|
||||
$objValidation->setAllowBlank(false);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setShowDropDown(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Value is not in list.');
|
||||
$objValidation->setPromptTitle('Pick from list');
|
||||
$objValidation->setPrompt('Please pick a value from the drop-down list.');
|
||||
$objValidation->setFormula1('$D$2:$D$6'); // Make sure NOT to put a range of cells or a formula between " and " !!!
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,143 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Create a first sheet
|
||||
echo date('H:i:s') , " Add data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Cell B3 and B5 contain data validation...")
|
||||
->setCellValue('A3', "Number:")
|
||||
->setCellValue('B3', "10")
|
||||
->setCellValue('A5', "List:")
|
||||
->setCellValue('B5', "Item A")
|
||||
->setCellValue('A7', "List #2:")
|
||||
->setCellValue('B7', "Item #2")
|
||||
->setCellValue('D2', "Item #1")
|
||||
->setCellValue('D3', "Item #2")
|
||||
->setCellValue('D4', "Item #3")
|
||||
->setCellValue('D5', "Item #4")
|
||||
->setCellValue('D6', "Item #5")
|
||||
;
|
||||
|
||||
|
||||
// Set data validation
|
||||
echo date('H:i:s') , " Set data validation" , EOL;
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
|
||||
$objValidation->setType( \PHPExcel\Cell\DataValidation::TYPE_WHOLE );
|
||||
$objValidation->setErrorStyle( \PHPExcel\Cell\DataValidation::STYLE_STOP );
|
||||
$objValidation->setAllowBlank(true);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Only numbers between 10 and 20 are allowed!');
|
||||
$objValidation->setPromptTitle('Allowed input');
|
||||
$objValidation->setPrompt('Only numbers between 10 and 20 are allowed.');
|
||||
$objValidation->setFormula1(10);
|
||||
$objValidation->setFormula2(20);
|
||||
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B5')->getDataValidation();
|
||||
$objValidation->setType( \PHPExcel\Cell\DataValidation::TYPE_LIST );
|
||||
$objValidation->setErrorStyle( \PHPExcel\Cell\DataValidation::STYLE_INFORMATION );
|
||||
$objValidation->setAllowBlank(false);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setShowDropDown(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Value is not in list.');
|
||||
$objValidation->setPromptTitle('Pick from list');
|
||||
$objValidation->setPrompt('Please pick a value from the drop-down list.');
|
||||
$objValidation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the list items between " and " if your list is simply a comma-separated list of values !!!
|
||||
|
||||
|
||||
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B7')->getDataValidation();
|
||||
$objValidation->setType( \PHPExcel\Cell\DataValidation::TYPE_LIST );
|
||||
$objValidation->setErrorStyle( \PHPExcel\Cell\DataValidation::STYLE_INFORMATION );
|
||||
$objValidation->setAllowBlank(false);
|
||||
$objValidation->setShowInputMessage(true);
|
||||
$objValidation->setShowErrorMessage(true);
|
||||
$objValidation->setShowDropDown(true);
|
||||
$objValidation->setErrorTitle('Input error');
|
||||
$objValidation->setError('Value is not in list.');
|
||||
$objValidation->setPromptTitle('Pick from list');
|
||||
$objValidation->setPrompt('Please pick a value from the drop-down list.');
|
||||
$objValidation->setFormula1('$D$2:$D$6'); // Make sure NOT to put a range of cells or a formula between " and " !!!
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
include "05featuredemo.inc.php";
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to CSV format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setSheetIndex(0)
|
||||
->save(str_replace('.php', '.csv', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Read from CSV format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
$objReader = \PHPExcel\IOFactory::createReader('CSV')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setSheetIndex(0);
|
||||
$objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__));
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to reload Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter2007 = \PHPExcel\IOFactory::createWriter($objPHPExcelFromCSV, 'Excel2007');
|
||||
$objWriter2007->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to CSV format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriterCSV = \PHPExcel\IOFactory::createWriter($objPHPExcelFromCSV, 'CSV');
|
||||
$objWriterCSV->setExcelCompatibility(true);
|
||||
$objWriterCSV->save(str_replace('.php', '_excel.csv', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '_excel.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
include "05featuredemo.inc.php";
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to HTML format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'HTML');
|
||||
$objWriter->setSheetIndex(0);
|
||||
//$objWriter->setImagesRoot('http://www.example.com');
|
||||
$objWriter->save(str_replace('.php', '.htm', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,108 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// List functions
|
||||
echo date('H:i:s') . " List implemented functions\n";
|
||||
$objCalc = \PHPExcel\Calculation::getInstance();
|
||||
print_r($objCalc->listFunctionNames());
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') . " Create new PHPExcel object\n";
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
echo date('H:i:s') . " Add some data\n";
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B3', 8);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B4', 10);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B5', True);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B6', False);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B7', 'Text String');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B9', '22');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B10', 4);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B11', 6);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B12', 12);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C2', 1);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C3', 2);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C4', 2);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C5', 3);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C6', 3);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C7', 3);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C8', '0');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C9', 4);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C10', 4);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C11', 4);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C12', 4);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D2', 2);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D3', 3);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D4', 4);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D5', '=((D2 * D3) + D4) & " should be 10"');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', 'Other functions');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E2', '=PI()');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E3', '=RAND()');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E4', '=RANDBETWEEN(5, 10)');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E14', 'Count of both ranges:');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F14', '=COUNT(B2:C12)');
|
||||
|
||||
// Calculated data
|
||||
echo date('H:i:s') . " Calculated data\n";
|
||||
echo 'Value of B14 [=COUNT(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B14')->getCalculatedValue() . "\r\n";
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') . " Done" , EOL;
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
||||
->setCellValue('A2', 'Lastname:')
|
||||
->setCellValue('A3', 'Fullname:')
|
||||
->setCellValue('B1', 'Maarten')
|
||||
->setCellValue('B2', 'Balliauw')
|
||||
->setCellValue('B3', '=B1 & " " & B2');
|
||||
|
||||
// Define named ranges
|
||||
echo date('H:i:s') , " Define named ranges" , EOL;
|
||||
$objPHPExcel->addNamedRange( new \PHPExcel\NamedRange('PersonName', $objPHPExcel->getActiveSheet(), 'B1') );
|
||||
$objPHPExcel->addNamedRange( new \PHPExcel\NamedRange('PersonLN', $objPHPExcel->getActiveSheet(), 'B2') );
|
||||
|
||||
// Rename named ranges
|
||||
echo date('H:i:s') , " Rename named ranges" , EOL;
|
||||
$objPHPExcel->getNamedRange('PersonName')->setName('PersonFN');
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Person');
|
||||
|
||||
|
||||
// Create a new worksheet, after the default sheet
|
||||
echo date('H:i:s') , " Create new Worksheet object" , EOL;
|
||||
$objPHPExcel->createSheet();
|
||||
|
||||
// Add some data to the second sheet, resembling some different data types
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(1);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
||||
->setCellValue('A2', 'Lastname:')
|
||||
->setCellValue('A3', 'Fullname:')
|
||||
->setCellValue('B1', '=PersonFN')
|
||||
->setCellValue('B2', '=PersonLN')
|
||||
->setCellValue('B3', '=PersonFN & " " & PersonLN');
|
||||
|
||||
// Resolve range
|
||||
echo date('H:i:s') , " Resolve range" , EOL;
|
||||
echo 'Cell B1 {=PersonFN}: ' , $objPHPExcel->getActiveSheet()->getCell('B1')->getCalculatedValue() , EOL;
|
||||
echo 'Cell B3 {=PersonFN & " " & PersonLN}: ' , $objPHPExcel->getActiveSheet()->getCell('B3')->getCalculatedValue() , EOL;
|
||||
echo 'Cell Person!B1: ' , $objPHPExcel->getActiveSheet()->getCell('Person!B1')->getCalculatedValue() , EOL;
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Person (cloned)');
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
if (!file_exists("14excel5.xls")) {
|
||||
exit("Please run 14excel5.php first.\n");
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load workbook from Excel5 file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objPHPExcel = \PHPExcel\IOFactory::load("14excel5.xls");
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo 'Call time to load Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done reading file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
include "05featuredemo.inc.php";
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Change these values to select the Rendering library that you wish to use
|
||||
// and its directory location on your server
|
||||
//$rendererName = \PHPExcel\Settings::PDF_RENDERER_TCPDF;
|
||||
//$rendererName = \PHPExcel\Settings::PDF_RENDERER_MPDF;
|
||||
$rendererName = \PHPExcel\Settings::PDF_RENDERER_DOMPDF;
|
||||
//$rendererLibrary = 'tcPDF5.9';
|
||||
//$rendererLibrary = 'mPDF5.4';
|
||||
$rendererLibrary = 'domPDF0.6.0beta3';
|
||||
$rendererLibraryPath = '/php/libraries/PDF/' . $rendererLibrary;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Hide grid lines" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setShowGridLines(false);
|
||||
|
||||
echo date('H:i:s') , " Set orientation to landscape" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to PDF format using {$rendererName}" , EOL;
|
||||
|
||||
if (!\PHPExcel\Settings::setPdfRenderer(
|
||||
$rendererName,
|
||||
$rendererLibraryPath
|
||||
)) {
|
||||
die(
|
||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||
EOL .
|
||||
'at the top of this script as appropriate for your directory structure'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF');
|
||||
$objWriter->setSheetIndex(0);
|
||||
$objWriter->save(str_replace('.php', '_'.$rendererName.'.pdf', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '_'.$rendererName.'.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:T100')->applyFromArray(
|
||||
array('fill' => array(
|
||||
'type' => \PHPExcel\Style\Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'FFCCFFCC')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => \PHPExcel\Style\Border::BORDER_THIN),
|
||||
'right' => array('style' => \PHPExcel\Style\Border::BORDER_MEDIUM)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
|
||||
array('fill' => array(
|
||||
'type' => \PHPExcel\Style\Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'FFFFFF00')
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,124 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
$sharedStyle1 = new \PHPExcel\Style();
|
||||
$sharedStyle2 = new \PHPExcel\Style();
|
||||
|
||||
$sharedStyle1->applyFromArray(
|
||||
array('fill' => array(
|
||||
'type' => \PHPExcel\Style\Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'FFCCFFCC')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => \PHPExcel\Style\Border::BORDER_THIN),
|
||||
'right' => array('style' => \PHPExcel\Style\Border::BORDER_MEDIUM)
|
||||
)
|
||||
));
|
||||
|
||||
$sharedStyle2->applyFromArray(
|
||||
array('fill' => array(
|
||||
'type' => \PHPExcel\Style\Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'FFFFFF00')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => \PHPExcel\Style\Border::BORDER_THIN),
|
||||
'right' => array('style' => \PHPExcel\Style\Border::BORDER_MEDIUM)
|
||||
)
|
||||
));
|
||||
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyle($sharedStyle1, "A1:T100");
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyle($sharedStyle2, "C5:R95");
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Check prerequisites
|
||||
if (!file_exists("06largescale.xlsx")) {
|
||||
exit("Please run 06largescale.php first.\n");
|
||||
}
|
||||
|
||||
class MyReadFilter implements \PHPExcel\Reader\IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
// Read title row and rows 20 - 30
|
||||
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
|
||||
$objReader = \PHPExcel\IOFactory::createReader('Excel2007');
|
||||
$objReader->setReadFilter( new MyReadFilter() );
|
||||
$objPHPExcel = $objReader->load("06largescale.xlsx");
|
||||
|
||||
echo date('H:i:s') , " Remove unnecessary rows" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->removeRow(2, 18);
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
// Generate an image
|
||||
echo date('H:i:s') , " Generate an image" , EOL;
|
||||
$gdImage = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream');
|
||||
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
|
||||
imagestring($gdImage, 1, 5, 5, 'Created with PHPExcel', $textColor);
|
||||
|
||||
// Add a drawing to the worksheet
|
||||
echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
|
||||
$objDrawing = new \PHPExcel\Worksheet\MemoryDrawing();
|
||||
$objDrawing->setName('Sample image');
|
||||
$objDrawing->setDescription('Sample image');
|
||||
$objDrawing->setImageResource($gdImage);
|
||||
$objDrawing->setRenderingFunction(\PHPExcel\Worksheet\MemoryDrawing::RENDERING_JPEG);
|
||||
$objDrawing->setMimeType(\PHPExcel\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT);
|
||||
$objDrawing->setHeight(36);
|
||||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to HTML format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'HTML');
|
||||
$objWriter->save(str_replace('.php', '.html', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.html', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,122 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Change these values to select the PDF Rendering library that you wish to use
|
||||
// and its directory location on your server
|
||||
//$rendererName = \PHPExcel\Settings::PDF_RENDERER_TCPDF;
|
||||
//$rendererName = \PHPExcel\Settings::PDF_RENDERER_MPDF;
|
||||
$rendererName = \PHPExcel\Settings::PDF_RENDERER_DOMPDF;
|
||||
//$rendererLibrary = 'tcPDF5.9';
|
||||
//$rendererLibrary = 'mPDF5.4';
|
||||
$rendererLibrary = 'domPDF0.6.0beta3';
|
||||
$rendererLibraryPath = '/php/libraries/PDF/' . $rendererLibrary;
|
||||
|
||||
|
||||
// Read from Excel2007 (.xlsx) template
|
||||
echo date('H:i:s') , " Load Excel2007 template file" , EOL;
|
||||
$objReader = \PHPExcel\IOFactory::createReader('Excel2007');
|
||||
$objPHPExcel = $objReader->load("templates/26template.xlsx");
|
||||
|
||||
/** at this point, we could do some manipulations with the template, but we skip this step */
|
||||
|
||||
// Export to Excel2007 (.xlsx)
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Export to Excel5 (.xls)
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Export to HTML (.html)
|
||||
echo date('H:i:s') , " Write to HTML format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'HTML');
|
||||
$objWriter->save(str_replace('.php', '.htm', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Export to PDF (.pdf)
|
||||
echo date('H:i:s') , " Write to PDF format" , EOL;
|
||||
try {
|
||||
if (!\PHPExcel\Settings::setPdfRenderer(
|
||||
$rendererName,
|
||||
$rendererLibraryPath
|
||||
)) {
|
||||
echo (
|
||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||
EOL .
|
||||
'at the top of this script as appropriate for your directory structure' .
|
||||
EOL
|
||||
);
|
||||
} else {
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF');
|
||||
$objWriter->save(str_replace('.php', '.pdf', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo date('H:i:s') , ' EXCEPTION: ', $e->getMessage() , EOL;
|
||||
}
|
||||
|
||||
// Remove first two rows with field headers before exporting to CSV
|
||||
echo date('H:i:s') , " Removing first two heading rows for CSV export" , EOL;
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->removeRow(1, 2);
|
||||
|
||||
// Export to CSV (.csv)
|
||||
echo date('H:i:s') , " Write to CSV format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'CSV');
|
||||
$objWriter->save(str_replace('.php', '.csv', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Export to CSV with BOM (.csv)
|
||||
echo date('H:i:s') , " Write to CSV format (with BOM)" , EOL;
|
||||
$objWriter->setUseBOM(true);
|
||||
$objWriter->save(str_replace('.php', '-bom.csv', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '-bom.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Read from Excel5 (.xls) template
|
||||
echo date('H:i:s') , " Load Excel2007 template file" , EOL;
|
||||
$objReader = \PHPExcel\IOFactory::createReader('Excel5');
|
||||
$objPHPExcel = $objReader->load("templates/27template.xls");
|
||||
|
||||
// Export to Excel2007 (.xlsx)
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Export to Excel5 (.xls)
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
if (!file_exists("05featuredemo.xlsx")) {
|
||||
exit("Please run 05featuredemo.php first." . EOL);
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
|
||||
$objReader = \PHPExcel\IOFactory::createReader('Excel2007');
|
||||
$objPHPExcel = $objReader->load("05featuredemo.xlsx");
|
||||
|
||||
echo date('H:i:s') , " Iterate worksheets" , EOL;
|
||||
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
||||
echo 'Worksheet - ' , $worksheet->getTitle() , EOL;
|
||||
|
||||
foreach ($worksheet->getRowIterator() as $row) {
|
||||
echo ' Row number - ' , $row->getRowIndex() , EOL;
|
||||
|
||||
$cellIterator = $row->getCellIterator();
|
||||
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
|
||||
foreach ($cellIterator as $cell) {
|
||||
if (!is_null($cell)) {
|
||||
echo ' Cell - ' , $cell->getCoordinate() , ' - ' , $cell->getCalculatedValue() , EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
|
@ -1,183 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Set timezone
|
||||
echo date('H:i:s') , " Set timezone" , EOL;
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Set value binder
|
||||
echo date('H:i:s') , " Set value binder" , EOL;
|
||||
\PHPExcel\Cell::setValueBinder( new \PHPExcel\Cell\AdvancedValueBinder() );
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||
->setKeywords("office 2007 openxml php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
// Set default font
|
||||
echo date('H:i:s') , " Set default font" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial');
|
||||
$objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10);
|
||||
|
||||
// Set column widths
|
||||
echo date('H:i:s') , " Set column widths" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(14);
|
||||
|
||||
// Add some data, resembling some different data types
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'String value:')
|
||||
->setCellValue('B1', 'Mark Baker');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Numeric value #1:')
|
||||
->setCellValue('B2', 12345);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Numeric value #2:')
|
||||
->setCellValue('B3', -12.345);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Numeric value #3:')
|
||||
->setCellValue('B4', .12345);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Numeric value #4:')
|
||||
->setCellValue('B5', '12345');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A6', 'Numeric value #5:')
|
||||
->setCellValue('B6', '1.2345');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A7', 'Numeric value #6:')
|
||||
->setCellValue('B7', '.12345');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A8', 'Numeric value #7:')
|
||||
->setCellValue('B8', '1.234e-5');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A9', 'Numeric value #8:')
|
||||
->setCellValue('B9', '-1.234e+5');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A10', 'Boolean value:')
|
||||
->setCellValue('B10', 'TRUE');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A11', 'Percentage value #1:')
|
||||
->setCellValue('B11', '10%');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A12', 'Percentage value #2:')
|
||||
->setCellValue('B12', '12.5%');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A13', 'Fraction value #1:')
|
||||
->setCellValue('B13', '-1/2');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A14', 'Fraction value #2:')
|
||||
->setCellValue('B14', '3 1/2');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A15', 'Fraction value #3:')
|
||||
->setCellValue('B15', '-12 3/4');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A16', 'Fraction value #4:')
|
||||
->setCellValue('B16', '13/4');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Currency value #1:')
|
||||
->setCellValue('B17', '$12345');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A18', 'Currency value #2:')
|
||||
->setCellValue('B18', '$12345.67');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A19', 'Currency value #3:')
|
||||
->setCellValue('B19', '$12,345.67');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A20', 'Date value #1:')
|
||||
->setCellValue('B20', '21 December 1983');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A21', 'Date value #2:')
|
||||
->setCellValue('B21', '19-Dec-1960');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A22', 'Date value #3:')
|
||||
->setCellValue('B22', '07/12/1982');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A23', 'Date value #4:')
|
||||
->setCellValue('B23', '24-11-1950');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A24', 'Date value #5:')
|
||||
->setCellValue('B24', '17-Mar');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A25', 'Time value #1:')
|
||||
->setCellValue('B25', '01:30');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A26', 'Time value #2:')
|
||||
->setCellValue('B26', '01:30:15');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A27', 'Date/Time value:')
|
||||
->setCellValue('B27', '19-Dec-1960 01:30');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A28', 'Formula:')
|
||||
->setCellValue('B28', '=SUM(B2:B9)');
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Advanced value binder');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load from Excel5 template" , EOL;
|
||||
$objReader = \PHPExcel\IOFactory::createReader('Excel5');
|
||||
$objPHPExcel = $objReader->load("templates/30template.xls");
|
||||
|
||||
|
||||
|
||||
|
||||
echo date('H:i:s') , " Add new data to the template" , EOL;
|
||||
$data = array(array('title' => 'Excel for dummies',
|
||||
'price' => 17.99,
|
||||
'quantity' => 2
|
||||
),
|
||||
array('title' => 'PHP for dummies',
|
||||
'price' => 15.99,
|
||||
'quantity' => 1
|
||||
),
|
||||
array('title' => 'Inside OOP',
|
||||
'price' => 12.95,
|
||||
'quantity' => 1
|
||||
)
|
||||
);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', \PHPExcel\Shared\Date::PHPToExcel(time()));
|
||||
|
||||
$baseRow = 5;
|
||||
foreach($data as $r => $dataRow) {
|
||||
$row = $baseRow + $r;
|
||||
$objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1);
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $r+1)
|
||||
->setCellValue('B'.$row, $dataRow['title'])
|
||||
->setCellValue('C'.$row, $dataRow['price'])
|
||||
->setCellValue('D'.$row, $dataRow['quantity'])
|
||||
->setCellValue('E'.$row, '=C'.$row.'*D'.$row);
|
||||
}
|
||||
$objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1);
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
$inputFileName = 'templates/31docproperties.xls';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load Tests from $inputFileType file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objPHPExcelReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
$objPHPExcel = $objPHPExcelReader->load($inputFileName);
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Adjust properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setTitle("Office 95 XLS Test Document")
|
||||
->setSubject("Office 95 XLS Test Document")
|
||||
->setDescription("Test XLS document, generated using PHPExcel")
|
||||
->setKeywords("office 95 biff php");
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;
|
||||
|
||||
|
||||
echo EOL;
|
||||
// Reread File
|
||||
echo date('H:i:s') , " Reread Excel5 file" , EOL;
|
||||
$objPHPExcelRead = \PHPExcel\IOFactory::load(str_replace('.php', '.xls', __FILE__));
|
||||
|
||||
// Set properties
|
||||
echo date('H:i:s') , " Get properties" , EOL;
|
||||
|
||||
echo 'Core Properties:' , EOL;
|
||||
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , EOL;
|
||||
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
|
||||
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL;
|
||||
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , EOL;
|
||||
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
|
||||
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL;
|
||||
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , EOL;
|
||||
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , EOL;
|
||||
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , EOL;
|
||||
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , EOL;
|
||||
|
||||
|
||||
echo 'Extended (Application) Properties:' , EOL;
|
||||
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , EOL;
|
||||
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , EOL;
|
||||
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , EOL;
|
||||
|
||||
|
||||
echo 'Custom Properties:' , EOL;
|
||||
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
|
||||
foreach($customProperties as $customProperty) {
|
||||
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
||||
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
||||
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
|
||||
if ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_DATE) {
|
||||
echo date('d-M-Y H:i:s',$propertyValue) , EOL;
|
||||
} elseif ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||
echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL;
|
||||
} else {
|
||||
echo $propertyValue , EOL;
|
||||
}
|
||||
}
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;
|
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel2007';
|
||||
$inputFileName = 'templates/31docproperties.xlsx';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load Tests from $inputFileType file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objPHPExcelReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
$objPHPExcel = $objPHPExcelReader->load($inputFileName);
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Adjust properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document")
|
||||
->setSubject("Office 2007 XLSX Test Document")
|
||||
->setDescription("Test XLSX document, generated using PHPExcel")
|
||||
->setKeywords("office 2007 openxml php");
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;
|
||||
|
||||
|
||||
echo EOL;
|
||||
// Reread File
|
||||
echo date('H:i:s') , " Reread Excel2007 file" , EOL;
|
||||
$objPHPExcelRead = \PHPExcel\IOFactory::load(str_replace('.php', '.xlsx', __FILE__));
|
||||
|
||||
// Set properties
|
||||
echo date('H:i:s') , " Get properties" , EOL;
|
||||
|
||||
echo 'Core Properties:' , EOL;
|
||||
echo ' Created by - ' , $objPHPExcel->getProperties()->getCreator() , EOL;
|
||||
echo ' Created on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getCreated()) , ' at ' ,
|
||||
date('H:i:s',$objPHPExcel->getProperties()->getCreated()) , EOL;
|
||||
echo ' Last Modified by - ' , $objPHPExcel->getProperties()->getLastModifiedBy() , EOL;
|
||||
echo ' Last Modified on - ' , date('d-M-Y',$objPHPExcel->getProperties()->getModified()) , ' at ' ,
|
||||
date('H:i:s',$objPHPExcel->getProperties()->getModified()) , EOL;
|
||||
echo ' Title - ' , $objPHPExcel->getProperties()->getTitle() , EOL;
|
||||
echo ' Subject - ' , $objPHPExcel->getProperties()->getSubject() , EOL;
|
||||
echo ' Description - ' , $objPHPExcel->getProperties()->getDescription() , EOL;
|
||||
echo ' Keywords: - ' , $objPHPExcel->getProperties()->getKeywords() , EOL;
|
||||
|
||||
|
||||
echo 'Extended (Application) Properties:' , EOL;
|
||||
echo ' Category - ' , $objPHPExcel->getProperties()->getCategory() , EOL;
|
||||
echo ' Company - ' , $objPHPExcel->getProperties()->getCompany() , EOL;
|
||||
echo ' Manager - ' , $objPHPExcel->getProperties()->getManager() , EOL;
|
||||
|
||||
|
||||
echo 'Custom Properties:' , EOL;
|
||||
$customProperties = $objPHPExcel->getProperties()->getCustomProperties();
|
||||
foreach($customProperties as $customProperty) {
|
||||
$propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
||||
$propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
||||
echo ' ' , $customProperty , ' - (' , $propertyType , ') - ';
|
||||
if ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_DATE) {
|
||||
echo date('d-M-Y H:i:s',$propertyValue) , EOL;
|
||||
} elseif ($propertyType == \PHPExcel\Document\Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||
echo (($propertyValue) ? 'TRUE' : 'FALSE') , EOL;
|
||||
} else {
|
||||
echo $propertyValue , EOL;
|
||||
}
|
||||
}
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) . " MB" , EOL;
|
|
@ -1,102 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Excel2007';
|
||||
$inputFileNames = 'templates/32readwrite*[0-9].xlsx';
|
||||
|
||||
if ((isset($argc)) && ($argc > 1)) {
|
||||
$inputFileNames = array();
|
||||
for($i = 1; $i < $argc; ++$i) {
|
||||
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
|
||||
}
|
||||
} else {
|
||||
$inputFileNames = glob($inputFileNames);
|
||||
}
|
||||
foreach($inputFileNames as $inputFileName) {
|
||||
$inputFileNameShort = basename($inputFileName);
|
||||
|
||||
if (!file_exists($inputFileName)) {
|
||||
echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL;
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
$objReader->setIncludeCharts(TRUE);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL;
|
||||
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
||||
$sheetName = $worksheet->getTitle();
|
||||
echo 'Worksheet: ' , $sheetName , EOL;
|
||||
|
||||
$chartNames = $worksheet->getChartNames();
|
||||
if(empty($chartNames)) {
|
||||
echo ' There are no charts in this worksheet' , EOL;
|
||||
} else {
|
||||
natsort($chartNames);
|
||||
foreach($chartNames as $i => $chartName) {
|
||||
$chart = $worksheet->getChartByName($chartName);
|
||||
if (!is_null($chart->getTitle())) {
|
||||
$caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"';
|
||||
} else {
|
||||
$caption = 'Untitled';
|
||||
}
|
||||
echo ' ' , $chartName , ' - ' , $caption , EOL;
|
||||
echo str_repeat(' ',strlen($chartName)+3);
|
||||
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
|
||||
if ($groupCount == 1) {
|
||||
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||
echo ' ' , $chartType , EOL;
|
||||
} else {
|
||||
$chartTypes = array();
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
}
|
||||
$chartTypes = array_unique($chartTypes);
|
||||
if (count($chartTypes) == 1) {
|
||||
$chartType = 'Multiple Plot ' . array_pop($chartTypes);
|
||||
echo ' ' , $chartType , EOL;
|
||||
} elseif (count($chartTypes) == 0) {
|
||||
echo ' *** Type not yet implemented' , EOL;
|
||||
} else {
|
||||
echo ' Combination Chart' , EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$outputFileName = basename($inputFileName);
|
||||
|
||||
echo date('H:i:s') , " Write Tests to Excel2007 file " , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save($outputFileName);
|
||||
echo date('H:i:s') , " File written to " , $outputFileName , EOL;
|
||||
|
||||
$objPHPExcel->disconnectWorksheets();
|
||||
unset($objPHPExcel);
|
||||
}
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,142 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues // plotValues
|
||||
);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_TOPRIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test %age-Stacked Area Chart');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('A7');
|
||||
$chart->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,145 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_STACKED, // plotGrouping
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues // plotValues
|
||||
);
|
||||
// Set additional dataseries parameters
|
||||
// Make it a horizontal bar rather than a vertical column graph
|
||||
$series->setPlotDirection(\PHPExcel\Chart\DataSeries::DIRECTION_BAR);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Chart');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('A7');
|
||||
$chart->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,145 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues // plotValues
|
||||
);
|
||||
// Set additional dataseries parameters
|
||||
// Make it a horizontal bar rather than a vertical column graph
|
||||
$series->setPlotDirection(\PHPExcel\Chart\DataSeries::DIRECTION_BAR);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Bar Chart');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('A7');
|
||||
$chart->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,154 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', '', 'Budget', 'Forecast', 'Actual'),
|
||||
array('2010', 'Q1', 47, 44, 43 ),
|
||||
array('', 'Q2', 56, 53, 50 ),
|
||||
array('', 'Q3', 52, 46, 45 ),
|
||||
array('', 'Q4', 45, 40, 40 ),
|
||||
array('2011', 'Q1', 51, 42, 46 ),
|
||||
array('', 'Q2', 53, 58, 56 ),
|
||||
array('', 'Q3', 64, 66, 69 ),
|
||||
array('', 'Q4', 54, 55, 56 ),
|
||||
array('2012', 'Q1', 49, 52, 58 ),
|
||||
array('', 'Q2', 68, 73, 86 ),
|
||||
array('', 'Q3', 72, 78, 0 ),
|
||||
array('', 'Q4', 50, 60, 0 ),
|
||||
)
|
||||
);
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 'Budget'
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 'Forecast'
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$E$1', NULL, 1), // 'Actual'
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$B$13', NULL, 12), // Q1 to Q4 for 2010 to 2012
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$E$2:$E$13', NULL, 12),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues // plotValues
|
||||
);
|
||||
// Set additional dataseries parameters
|
||||
// Make it a vertical column rather than a horizontal bar graph
|
||||
$series->setPlotDirection(\PHPExcel\Chart\DataSeries::DIRECTION_COL);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_BOTTOM, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Grouped Column Chart');
|
||||
$xAxisLabel = new \PHPExcel\Chart\Title('Financial Period');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
$xAxisLabel, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('G2');
|
||||
$chart->setBottomRightPosition('P20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,145 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues // plotValues
|
||||
);
|
||||
// Set additional dataseries parameters
|
||||
// Make it a vertical column rather than a horizontal bar graph
|
||||
$series->setPlotDirection(\PHPExcel\Chart\DataSeries::DIRECTION_COL);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Column Chart');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('A7');
|
||||
$chart->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,203 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'),
|
||||
array('Jan', 78, 52, 61),
|
||||
array('Feb', 64, 54, 62),
|
||||
array('Mar', 62, 57, 63),
|
||||
array('Apr', 21, 62, 59),
|
||||
array('May', 11, 75, 60),
|
||||
array('Jun', 1, 75, 57),
|
||||
array('Jul', 1, 79, 56),
|
||||
array('Aug', 1, 79, 59),
|
||||
array('Sep', 10, 75, 60),
|
||||
array('Oct', 40, 68, 63),
|
||||
array('Nov', 69, 62, 64),
|
||||
array('Dec', 89, 57, 66),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature
|
||||
);
|
||||
$dataSeriesLabels2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall
|
||||
);
|
||||
$dataSeriesLabels3 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity
|
||||
);
|
||||
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec
|
||||
);
|
||||
|
||||
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', NULL, 12),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series1 = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_CLUSTERED, // plotGrouping
|
||||
range(0, count($dataSeriesValues1)-1), // plotOrder
|
||||
$dataSeriesLabels1, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues1 // plotValues
|
||||
);
|
||||
// Set additional dataseries parameters
|
||||
// Make it a vertical column rather than a horizontal bar graph
|
||||
$series1->setPlotDirection(\PHPExcel\Chart\DataSeries::DIRECTION_COL);
|
||||
|
||||
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series2 = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_LINECHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping
|
||||
range(0, count($dataSeriesValues2)-1), // plotOrder
|
||||
$dataSeriesLabels2, // plotLabel
|
||||
NULL, // plotCategory
|
||||
$dataSeriesValues2 // plotValues
|
||||
);
|
||||
|
||||
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues3 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series3 = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping
|
||||
range(0, count($dataSeriesValues2)-1), // plotOrder
|
||||
$dataSeriesLabels3, // plotLabel
|
||||
NULL, // plotCategory
|
||||
$dataSeriesValues3 // plotValues
|
||||
);
|
||||
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series1, $series2, $series3));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Average Weather Chart for Crete');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
NULL // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('F2');
|
||||
$chart->setBottomRightPosition('O16');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,142 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_LINECHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_STACKED, // plotGrouping
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues // plotValues
|
||||
);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_TOPRIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Stacked Line Chart');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('A7');
|
||||
$chart->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,220 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series1 = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_AREACHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping
|
||||
range(0, count($dataSeriesValues1)-1), // plotOrder
|
||||
$dataSeriesLabels1, // plotLabel
|
||||
$xAxisTickValues1, // plotCategory
|
||||
$dataSeriesValues1 // plotValues
|
||||
);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea1 = new \PHPExcel\Chart\PlotArea(NULL, array($series1));
|
||||
// Set the chart legend
|
||||
$legend1 = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_TOPRIGHT, NULL, false);
|
||||
|
||||
$title1 = new \PHPExcel\Chart\Title('Test %age-Stacked Area Chart');
|
||||
$yAxisLabel1 = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart1 = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title1, // title
|
||||
$legend1, // legend
|
||||
$plotArea1, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel1 // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart1->setTopLeftPosition('A7');
|
||||
$chart1->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart1);
|
||||
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series2 = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_BARCHART, // plotType
|
||||
\PHPExcel\Chart\DataSeries::GROUPING_STANDARD, // plotGrouping
|
||||
range(0, count($dataSeriesValues2)-1), // plotOrder
|
||||
$dataSeriesLabels2, // plotLabel
|
||||
$xAxisTickValues2, // plotCategory
|
||||
$dataSeriesValues2 // plotValues
|
||||
);
|
||||
// Set additional dataseries parameters
|
||||
// Make it a vertical column rather than a horizontal bar graph
|
||||
$series2->setPlotDirection(\PHPExcel\Chart\DataSeries::DIRECTION_COL);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea2 = new \PHPExcel\Chart\PlotArea(NULL, array($series2));
|
||||
// Set the chart legend
|
||||
$legend2 = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title2 = new \PHPExcel\Chart\Title('Test Column Chart');
|
||||
$yAxisLabel2 = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart2 = new \PHPExcel\Chart(
|
||||
'chart2', // name
|
||||
$title2, // title
|
||||
$legend2, // legend
|
||||
$plotArea2, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel2 // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart2->setTopLeftPosition('I7');
|
||||
$chart2->setBottomRightPosition('P20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart2);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,215 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues1 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series1 = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_PIECHART, // plotType
|
||||
NULL, // plotGrouping (Pie charts don't have any grouping)
|
||||
range(0, count($dataSeriesValues1)-1), // plotOrder
|
||||
$dataSeriesLabels1, // plotLabel
|
||||
$xAxisTickValues1, // plotCategory
|
||||
$dataSeriesValues1 // plotValues
|
||||
);
|
||||
|
||||
// Set up a layout object for the Pie chart
|
||||
$layout1 = new \PHPExcel\Chart\Layout();
|
||||
$layout1->setShowVal(TRUE);
|
||||
$layout1->setShowPercent(TRUE);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea1 = new \PHPExcel\Chart\PlotArea($layout1, array($series1));
|
||||
// Set the chart legend
|
||||
$legend1 = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title1 = new \PHPExcel\Chart\Title('Test Pie Chart');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart1 = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title1, // title
|
||||
$legend1, // legend
|
||||
$plotArea1, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
NULL // yAxisLabel - Pie charts don't have a Y-Axis
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart1->setTopLeftPosition('A7');
|
||||
$chart1->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart1);
|
||||
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues2 = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series2 = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_DONUTCHART, // plotType
|
||||
NULL, // plotGrouping (Donut charts don't have any grouping)
|
||||
range(0, count($dataSeriesValues2)-1), // plotOrder
|
||||
$dataSeriesLabels2, // plotLabel
|
||||
$xAxisTickValues2, // plotCategory
|
||||
$dataSeriesValues2 // plotValues
|
||||
);
|
||||
|
||||
// Set up a layout object for the Pie chart
|
||||
$layout2 = new \PHPExcel\Chart\Layout();
|
||||
$layout2->setShowVal(TRUE);
|
||||
$layout2->setShowCatName(TRUE);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea2 = new \PHPExcel\Chart\PlotArea($layout2, array($series2));
|
||||
|
||||
$title2 = new \PHPExcel\Chart\Title('Test Donut Chart');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart2 = new \PHPExcel\Chart(
|
||||
'chart2', // name
|
||||
$title2, // title
|
||||
NULL, // legend
|
||||
$plotArea2, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
NULL // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart2->setTopLeftPosition('I7');
|
||||
$chart2->setBottomRightPosition('P20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart2);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,155 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Jan', 47, 45, 71),
|
||||
array('Feb', 56, 73, 86),
|
||||
array('Mar', 52, 61, 69),
|
||||
array('Apr', 40, 52, 60),
|
||||
array('May', 42, 55, 71),
|
||||
array('Jun', 58, 63, 76),
|
||||
array('Jul', 53, 61, 89),
|
||||
array('Aug', 46, 69, 85),
|
||||
array('Sep', 62, 75, 81),
|
||||
array('Oct', 51, 70, 96),
|
||||
array('Nov', 55, 66, 89),
|
||||
array('Dec', 68, 62, 0),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_RADARCHART, // plotType
|
||||
NULL, // plotGrouping (Radar charts don't have any grouping)
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues, // plotValues
|
||||
NULL, // plotDirection
|
||||
NULL, // smooth line
|
||||
\PHPExcel\Chart\DataSeries::STYLE_MARKER // plotStyle
|
||||
);
|
||||
|
||||
// Set up a layout object for the Pie chart
|
||||
$layout = new \PHPExcel\Chart\Layout();
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea($layout, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Radar Chart');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
NULL // yAxisLabel - Radar charts don't have a Y-Axis
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('F2');
|
||||
$chart->setBottomRightPosition('M15');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('', 2010, 2011, 2012),
|
||||
array('Q1', 12, 15, 21),
|
||||
array('Q2', 56, 73, 86),
|
||||
array('Q3', 52, 61, 69),
|
||||
array('Q4', 30, 32, 0),
|
||||
)
|
||||
);
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_SCATTERCHART, // plotType
|
||||
NULL, // plotGrouping (Scatter charts don't have any grouping)
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues, // plotValues
|
||||
NULL, // plotDirection
|
||||
NULL, // smooth line
|
||||
\PHPExcel\Chart\DataSeries::STYLE_LINEMARKER // plotStyle
|
||||
);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_TOPRIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Scatter Chart');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Value ($k)');
|
||||
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'chart1', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
NULL, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('A7');
|
||||
$chart->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,151 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array('Counts', 'Max', 'Min', 'Min Threshold', 'Max Threshold' ),
|
||||
array(10, 10, 5, 0, 50 ),
|
||||
array(30, 20, 10, 0, 50 ),
|
||||
array(20, 30, 15, 0, 50 ),
|
||||
array(40, 10, 0, 0, 50 ),
|
||||
array(100, 40, 5, 0, 50 ),
|
||||
), null, 'A1', true
|
||||
);
|
||||
$objWorksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(PHPExcel\Style\NumberFormat::FORMAT_NUMBER_00);
|
||||
|
||||
|
||||
// Set the Labels for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesLabels = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), //Max / Open
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), //Min / Close
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), //Min Threshold / Min
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$E$1', NULL, 1), //Max Threshold / Max
|
||||
);
|
||||
// Set the X-Axis Labels
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$xAxisTickValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('String', 'Worksheet!$A$2:$A$6', NULL, 5), // Counts
|
||||
);
|
||||
// Set the Data values for each data series we want to plot
|
||||
// Datatype
|
||||
// Cell reference for data
|
||||
// Format Code
|
||||
// Number of datapoints in series
|
||||
// Data values
|
||||
// Data Marker
|
||||
$dataSeriesValues = array(
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$B$2:$B$6', NULL, 5),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$C$2:$C$6', NULL, 5),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$D$2:$D$6', NULL, 5),
|
||||
new \PHPExcel\Chart\DataSeriesValues('Number', 'Worksheet!$E$2:$E$6', NULL, 5),
|
||||
);
|
||||
|
||||
// Build the dataseries
|
||||
$series = new \PHPExcel\Chart\DataSeries(
|
||||
\PHPExcel\Chart\DataSeries::TYPE_STOCKCHART, // plotType
|
||||
null, // plotGrouping - if we set this to not null, then xlsx throws error
|
||||
range(0, count($dataSeriesValues)-1), // plotOrder
|
||||
$dataSeriesLabels, // plotLabel
|
||||
$xAxisTickValues, // plotCategory
|
||||
$dataSeriesValues // plotValues
|
||||
);
|
||||
|
||||
// Set the series in the plot area
|
||||
$plotArea = new \PHPExcel\Chart\PlotArea(NULL, array($series));
|
||||
// Set the chart legend
|
||||
$legend = new \PHPExcel\Chart\Legend(\PHPExcel\Chart\Legend::POSITION_RIGHT, NULL, false);
|
||||
|
||||
$title = new \PHPExcel\Chart\Title('Test Stock Chart');
|
||||
$xAxisLabel = new \PHPExcel\Chart\Title('Counts');
|
||||
$yAxisLabel = new \PHPExcel\Chart\Title('Values');
|
||||
|
||||
// Create the chart
|
||||
$chart = new \PHPExcel\Chart(
|
||||
'stock-chart', // name
|
||||
$title, // title
|
||||
$legend, // legend
|
||||
$plotArea, // plotArea
|
||||
true, // plotVisibleOnly
|
||||
0, // displayBlanksAs
|
||||
$xAxisLabel, // xAxisLabel
|
||||
$yAxisLabel // yAxisLabel
|
||||
);
|
||||
|
||||
// Set the position where the chart should appear in the worksheet
|
||||
$chart->setTopLeftPosition('A7');
|
||||
$chart->setBottomRightPosition('H20');
|
||||
|
||||
// Add the chart to the worksheet
|
||||
$objWorksheet->addChart($chart);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$filename = str_replace('.php', '.xlsx', __FILE__);
|
||||
if(file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
$objWriter->save($filename);
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
if (!file_exists("33chartcreate-bar.xlsx")) {
|
||||
exit("Please run 33chartcreate-bar.php first." . EOL);
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
|
||||
$objReader = \PHPExcel\IOFactory::createReader("Excel2007");
|
||||
$objReader->setIncludeCharts(TRUE);
|
||||
$objPHPExcel = $objReader->load("33chartcreate-bar.xlsx");
|
||||
|
||||
|
||||
echo date('H:i:s') , " Update cell data values that are displayed in the chart" , EOL;
|
||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||
$objWorksheet->fromArray(
|
||||
array(
|
||||
array(50-12, 50-15, 50-21),
|
||||
array(50-56, 50-73, 50-86),
|
||||
array(50-52, 50-61, 50-69),
|
||||
array(50-30, 50-32, 50),
|
||||
),
|
||||
NULL,
|
||||
'B2'
|
||||
);
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Change these values to select the Rendering library that you wish to use
|
||||
// and its directory location on your server
|
||||
$rendererName = PHPExcel\Settings::CHART_RENDERER_JPGRAPH;
|
||||
$rendererLibrary = 'jpgraph3.5.0b1/src/';
|
||||
$rendererLibraryPath = '/php/libraries/Charts/' . $rendererLibrary;
|
||||
|
||||
|
||||
if (!PHPExcel\Settings::setChartRenderer(
|
||||
$rendererName,
|
||||
$rendererLibraryPath
|
||||
)) {
|
||||
die(
|
||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||
EOL .
|
||||
'at the top of this script as appropriate for your directory structure'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$inputFileType = 'Excel2007';
|
||||
$inputFileNames = 'templates/32readwrite*[0-9].xlsx';
|
||||
|
||||
if ((isset($argc)) && ($argc > 1)) {
|
||||
$inputFileNames = array();
|
||||
for($i = 1; $i < $argc; ++$i) {
|
||||
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
|
||||
}
|
||||
} else {
|
||||
$inputFileNames = glob($inputFileNames);
|
||||
}
|
||||
foreach($inputFileNames as $inputFileName) {
|
||||
$inputFileNameShort = basename($inputFileName);
|
||||
|
||||
if (!file_exists($inputFileName)) {
|
||||
echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL;
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
$objReader->setIncludeCharts(TRUE);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL;
|
||||
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
||||
$sheetName = $worksheet->getTitle();
|
||||
echo 'Worksheet: ' , $sheetName , EOL;
|
||||
|
||||
$chartNames = $worksheet->getChartNames();
|
||||
if(empty($chartNames)) {
|
||||
echo ' There are no charts in this worksheet' , EOL;
|
||||
} else {
|
||||
natsort($chartNames);
|
||||
foreach($chartNames as $i => $chartName) {
|
||||
$chart = $worksheet->getChartByName($chartName);
|
||||
if (!is_null($chart->getTitle())) {
|
||||
$caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"';
|
||||
} else {
|
||||
$caption = 'Untitled';
|
||||
}
|
||||
echo ' ' , $chartName , ' - ' , $caption , EOL;
|
||||
echo str_repeat(' ',strlen($chartName)+3);
|
||||
|
||||
$jpegFile = '35'.str_replace('.xlsx', '.jpg', substr($inputFileNameShort,2));
|
||||
if (file_exists($jpegFile)) {
|
||||
unlink($jpegFile);
|
||||
}
|
||||
try {
|
||||
$chart->render($jpegFile);
|
||||
} catch (Exception $e) {
|
||||
echo 'Error rendering chart: ',$e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$objPHPExcel->disconnectWorksheets();
|
||||
unset($objPHPExcel);
|
||||
}
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done rendering charts as images" , EOL;
|
||||
echo 'Image files have been created in ' , getcwd() , EOL;
|
|
@ -1,122 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Change these values to select the Rendering library that you wish to use
|
||||
// and its directory location on your server
|
||||
$rendererName = PHPExcel\Settings::CHART_RENDERER_JPGRAPH;
|
||||
$rendererLibrary = 'jpgraph3.5.0b1/src/';
|
||||
$rendererLibraryPath = '/php/libraries/Charts/' . $rendererLibrary;
|
||||
|
||||
|
||||
if (!PHPExcel\Settings::setChartRenderer(
|
||||
$rendererName,
|
||||
$rendererLibraryPath
|
||||
)) {
|
||||
die(
|
||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||
EOL .
|
||||
'at the top of this script as appropriate for your directory structure'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$inputFileType = 'Excel2007';
|
||||
$inputFileNames = 'templates/36write*.xlsx';
|
||||
|
||||
if ((isset($argc)) && ($argc > 1)) {
|
||||
$inputFileNames = array();
|
||||
for($i = 1; $i < $argc; ++$i) {
|
||||
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
|
||||
}
|
||||
} else {
|
||||
$inputFileNames = glob($inputFileNames);
|
||||
}
|
||||
foreach($inputFileNames as $inputFileName) {
|
||||
$inputFileNameShort = basename($inputFileName);
|
||||
|
||||
if (!file_exists($inputFileName)) {
|
||||
echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL;
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
$objReader->setIncludeCharts(TRUE);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL;
|
||||
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
||||
$sheetName = $worksheet->getTitle();
|
||||
echo 'Worksheet: ' , $sheetName , EOL;
|
||||
|
||||
$chartNames = $worksheet->getChartNames();
|
||||
if(empty($chartNames)) {
|
||||
echo ' There are no charts in this worksheet' , EOL;
|
||||
} else {
|
||||
natsort($chartNames);
|
||||
foreach($chartNames as $i => $chartName) {
|
||||
$chart = $worksheet->getChartByName($chartName);
|
||||
if (!is_null($chart->getTitle())) {
|
||||
$caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"';
|
||||
} else {
|
||||
$caption = 'Untitled';
|
||||
}
|
||||
echo ' ' , $chartName , ' - ' , $caption , EOL;
|
||||
echo str_repeat(' ',strlen($chartName)+3);
|
||||
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
|
||||
if ($groupCount == 1) {
|
||||
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||
echo ' ' , $chartType , EOL;
|
||||
} else {
|
||||
$chartTypes = array();
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
}
|
||||
$chartTypes = array_unique($chartTypes);
|
||||
if (count($chartTypes) == 1) {
|
||||
$chartType = 'Multiple Plot ' . array_pop($chartTypes);
|
||||
echo ' ' , $chartType , EOL;
|
||||
} elseif (count($chartTypes) == 0) {
|
||||
echo ' *** Type not yet implemented' , EOL;
|
||||
} else {
|
||||
echo ' Combination Chart' , EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$outputFileName = str_replace('.xlsx', '.html', basename($inputFileName));
|
||||
|
||||
echo date('H:i:s') , " Write Tests to HTML file " , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'HTML');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save($outputFileName);
|
||||
echo date('H:i:s') , " File written to " , $outputFileName , EOL;
|
||||
|
||||
$objPHPExcel->disconnectWorksheets();
|
||||
unset($objPHPExcel);
|
||||
}
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,145 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Change these values to select the Rendering library that you wish to use
|
||||
// for PDF files, and its directory location on your server
|
||||
//$rendererName = PHPExcel\Settings::PDF_RENDERER_TCPDF;
|
||||
$rendererName = PHPExcel\Settings::PDF_RENDERER_MPDF;
|
||||
//$rendererName = PHPExcel\Settings::PDF_RENDERER_DOMPDF;
|
||||
//$rendererLibrary = 'tcPDF5.9';
|
||||
$rendererLibrary = 'mPDF5.4';
|
||||
//$rendererLibrary = 'domPDF0.6.0beta3';
|
||||
$rendererLibraryPath = '/php/libraries/PDF/' . $rendererLibrary;
|
||||
|
||||
|
||||
if (!PHPExcel\Settings::setPdfRenderer(
|
||||
$rendererName,
|
||||
$rendererLibraryPath
|
||||
)) {
|
||||
die(
|
||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||
EOL .
|
||||
'at the top of this script as appropriate for your directory structure'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Change these values to select the Rendering library that you wish to use
|
||||
// for Chart images, and its directory location on your server
|
||||
$rendererName = PHPExcel\Settings::CHART_RENDERER_JPGRAPH;
|
||||
$rendererLibrary = 'jpgraph3.5.0b1/src/';
|
||||
$rendererLibraryPath = '/php/libraries/Charts/' . $rendererLibrary;
|
||||
|
||||
|
||||
if (!PHPExcel\Settings::setChartRenderer(
|
||||
$rendererName,
|
||||
$rendererLibraryPath
|
||||
)) {
|
||||
die(
|
||||
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
|
||||
EOL .
|
||||
'at the top of this script as appropriate for your directory structure'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$inputFileType = 'Excel2007';
|
||||
$inputFileNames = 'templates/36write*.xlsx';
|
||||
|
||||
if ((isset($argc)) && ($argc > 1)) {
|
||||
$inputFileNames = array();
|
||||
for($i = 1; $i < $argc; ++$i) {
|
||||
$inputFileNames[] = dirname(__FILE__) . '/templates/' . $argv[$i];
|
||||
}
|
||||
} else {
|
||||
$inputFileNames = glob($inputFileNames);
|
||||
}
|
||||
foreach($inputFileNames as $inputFileName) {
|
||||
$inputFileNameShort = basename($inputFileName);
|
||||
|
||||
if (!file_exists($inputFileName)) {
|
||||
echo date('H:i:s') , " File " , $inputFileNameShort , ' does not exist' , EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Load Test from $inputFileType file " , $inputFileNameShort , EOL;
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
$objReader->setIncludeCharts(TRUE);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo date('H:i:s') , " Iterate worksheets looking at the charts" , EOL;
|
||||
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
|
||||
$sheetName = $worksheet->getTitle();
|
||||
echo 'Worksheet: ' , $sheetName , EOL;
|
||||
|
||||
$chartNames = $worksheet->getChartNames();
|
||||
if(empty($chartNames)) {
|
||||
echo ' There are no charts in this worksheet' , EOL;
|
||||
} else {
|
||||
natsort($chartNames);
|
||||
foreach($chartNames as $i => $chartName) {
|
||||
$chart = $worksheet->getChartByName($chartName);
|
||||
if (!is_null($chart->getTitle())) {
|
||||
$caption = '"' . implode(' ',$chart->getTitle()->getCaption()) . '"';
|
||||
} else {
|
||||
$caption = 'Untitled';
|
||||
}
|
||||
echo ' ' , $chartName , ' - ' , $caption , EOL;
|
||||
echo str_repeat(' ',strlen($chartName)+3);
|
||||
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
|
||||
if ($groupCount == 1) {
|
||||
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||
echo ' ' , $chartType , EOL;
|
||||
} else {
|
||||
$chartTypes = array();
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
}
|
||||
$chartTypes = array_unique($chartTypes);
|
||||
if (count($chartTypes) == 1) {
|
||||
$chartType = 'Multiple Plot ' . array_pop($chartTypes);
|
||||
echo ' ' , $chartType , EOL;
|
||||
} elseif (count($chartTypes) == 0) {
|
||||
echo ' *** Type not yet implemented' , EOL;
|
||||
} else {
|
||||
echo ' Combination Chart' , EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$outputFileName = str_replace('.xlsx', '.pdf', basename($inputFileName));
|
||||
|
||||
echo date('H:i:s') , " Write Tests to HTML file " , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'PDF');
|
||||
$objWriter->setIncludeCharts(TRUE);
|
||||
$objWriter->save($outputFileName);
|
||||
echo date('H:i:s') , " File written to " , $outputFileName , EOL;
|
||||
|
||||
$objPHPExcel->disconnectWorksheets();
|
||||
unset($objPHPExcel);
|
||||
}
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , ' Peak memory usage: ' , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("PHPOffice")
|
||||
->setLastModifiedBy("PHPOffice")
|
||||
->setTitle("PHPExcel Test Document")
|
||||
->setSubject("PHPExcel Test Document")
|
||||
->setDescription("Test document for PHPExcel, generated using PHP classes.")
|
||||
->setKeywords("Office PHPExcel php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!');
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
// Set the page layout view as page layout
|
||||
$objPHPExcel->getActiveSheet()->getSheetView()->setView(PHPExcel\Worksheet\SheetView::SHEETVIEW_PAGE_LAYOUT);
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,118 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("PHPExcel Test Document")
|
||||
->setSubject("PHPExcel Test Document")
|
||||
->setDescription("Test document for PHPExcel, generated using PHP classes.")
|
||||
->setKeywords("office PHPExcel php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!')
|
||||
->setCellValue('C1', 'Hello')
|
||||
->setCellValue('D2', 'world!');
|
||||
|
||||
// Miscellaneous glyphs, UTF-8
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', 'Miscellaneous glyphs')
|
||||
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A8',"Hello\nWorld");
|
||||
$objPHPExcel->getActiveSheet()->getRowDimension(8)->setRowHeight(-1);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A8')->getAlignment()->setWrapText(true);
|
||||
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
|
||||
// Clone worksheet
|
||||
echo date('H:i:s') , " Clone worksheet" , EOL;
|
||||
$clonedSheet = clone $objPHPExcel->getActiveSheet();
|
||||
$clonedSheet
|
||||
->setCellValue('A1', 'Goodbye')
|
||||
->setCellValue('A2', 'cruel')
|
||||
->setCellValue('C1', 'Goodbye')
|
||||
->setCellValue('C2', 'cruel');
|
||||
|
||||
// Rename cloned worksheet
|
||||
echo date('H:i:s') , " Rename cloned worksheet" , EOL;
|
||||
$clonedSheet->setTitle('Simple Clone');
|
||||
$objPHPExcel->addSheet($clonedSheet);
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,175 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()
|
||||
->setCreator("PHPOffice")
|
||||
->setLastModifiedBy("PHPOffice")
|
||||
->setTitle("PHPExcel Test Document")
|
||||
->setSubject("PHPExcel Test Document")
|
||||
->setDescription("Test document for PHPExcel, generated using PHP classes.")
|
||||
->setKeywords("Office PHPExcel php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
function transpose($value) {
|
||||
return array($value);
|
||||
}
|
||||
|
||||
// Add some data
|
||||
$continentColumn = 'D';
|
||||
$column = 'F';
|
||||
|
||||
// Set data for dropdowns
|
||||
foreach(glob('./data/continents/*') as $key => $filename) {
|
||||
$continent = pathinfo($filename, PATHINFO_FILENAME);
|
||||
echo "Loading $continent", EOL;
|
||||
$continent = str_replace(' ','_',$continent);
|
||||
$countries = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
$countryCount = count($countries);
|
||||
|
||||
// Transpose $countries from a row to a column array
|
||||
$countries = array_map('transpose', $countries);
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->fromArray($countries, null, $column . '1');
|
||||
$objPHPExcel->addNamedRange(
|
||||
new PHPExcel\NamedRange(
|
||||
$continent,
|
||||
$objPHPExcel->getActiveSheet(), $column . '1:' . $column . $countryCount
|
||||
)
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getColumnDimension($column)
|
||||
->setVisible(false);
|
||||
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue($continentColumn . ($key+1), $continent);
|
||||
|
||||
++$column;
|
||||
}
|
||||
|
||||
// Hide the dropdown data
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getColumnDimension($continentColumn)
|
||||
->setVisible(false);
|
||||
|
||||
$objPHPExcel->addNamedRange(
|
||||
new PHPExcel\NamedRange(
|
||||
'Continents',
|
||||
$objPHPExcel->getActiveSheet(), $continentColumn . '1:' . $continentColumn . ($key+1)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Set selection cells
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('A1', 'Continent:');
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('B1', 'Select continent');
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('B3', '=' . $column . 1);
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('B3', 'Select country');
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getStyle('A1:A3')
|
||||
->getFont()->setBold(true);
|
||||
|
||||
// Set linked validators
|
||||
$objValidation = $objPHPExcel->getActiveSheet()
|
||||
->getCell('B1')
|
||||
->getDataValidation();
|
||||
$objValidation->setType( PHPExcel\Cell\DataValidation::TYPE_LIST )
|
||||
->setErrorStyle( PHPExcel\Cell\DataValidation::STYLE_INFORMATION )
|
||||
->setAllowBlank(false)
|
||||
->setShowInputMessage(true)
|
||||
->setShowErrorMessage(true)
|
||||
->setShowDropDown(true)
|
||||
->setErrorTitle('Input error')
|
||||
->setError('Continent is not in the list.')
|
||||
->setPromptTitle('Pick from the list')
|
||||
->setPrompt('Please pick a continent from the drop-down list.')
|
||||
->setFormula1('=Continents');
|
||||
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('A3', 'Country:');
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getStyle('A3')
|
||||
->getFont()->setBold(true);
|
||||
|
||||
$objValidation = $objPHPExcel->getActiveSheet()
|
||||
->getCell('B3')
|
||||
->getDataValidation();
|
||||
$objValidation->setType( PHPExcel\Cell\DataValidation::TYPE_LIST )
|
||||
->setErrorStyle( PHPExcel\Cell\DataValidation::STYLE_INFORMATION )
|
||||
->setAllowBlank(false)
|
||||
->setShowInputMessage(true)
|
||||
->setShowErrorMessage(true)
|
||||
->setShowDropDown(true)
|
||||
->setErrorTitle('Input error')
|
||||
->setError('Country is not in the list.')
|
||||
->setPromptTitle('Pick from the list')
|
||||
->setPrompt('Please pick a country from the drop-down list.')
|
||||
->setFormula1('=INDIRECT($B$1)');
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(12);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
// Save Excel 2007 file
|
||||
// This linked validation list method only seems to work for Excel2007, not for Excel5
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
$worksheet = $objPHPExcel->getActiveSheet();
|
||||
|
||||
echo date('H:i:s') , " Create styles array" , EOL;
|
||||
$styles = array();
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$style = new \PHPExcel\Style();
|
||||
$style->getFont()->setSize($i + 4);
|
||||
$styles[] = $style;
|
||||
}
|
||||
|
||||
echo date('H:i:s') , " Add data (begin)" , EOL;
|
||||
$t = microtime(true);
|
||||
for ($col = 0; $col < 50; $col++) {
|
||||
for ($row = 0; $row < 100; $row++) {
|
||||
$str = ($row + $col);
|
||||
$style = $styles[$row % 10];
|
||||
$coord = \PHPExcel\Cell::stringFromColumnIndex($col) . ($row + 1);
|
||||
$worksheet->setCellValue($coord, $str);
|
||||
$worksheet->duplicateStyle($style, $coord);
|
||||
}
|
||||
}
|
||||
$d = microtime(true) - $t;
|
||||
echo date('H:i:s') , " Add data (end), time: " . round($d, 2) . " s", EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
include "05featuredemo.inc.php";
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Set password against the spreadsheet file
|
||||
$objPHPExcel->getSecurity()->setLockWindows(true);
|
||||
$objPHPExcel->getSecurity()->setLockStructure(true);
|
||||
$objPHPExcel->getSecurity()->setWorkbookPassword('secret');
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,171 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new \PHPExcel\Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("PHPExcel Test Document")
|
||||
->setSubject("PHPExcel Test Document")
|
||||
->setDescription("Test document for PHPExcel, generated using PHP classes.")
|
||||
->setKeywords("office PHPExcel php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
|
||||
$html1 = '<font color="#0000ff">
|
||||
<h1 align="center">My very first example of rich text<br />generated from html markup</h1>
|
||||
<p>
|
||||
<font size="14" COLOR="rgb(0,255,128)">
|
||||
<b>This block</b> contains an <i>italicized</i> word;
|
||||
while this block uses an <u>underline</u>.
|
||||
</font>
|
||||
</p>
|
||||
<p align="right"><font size="9" color="red">
|
||||
I want to eat <ins><del>healthy food</del> <strong>pizza</strong></ins>.
|
||||
</font>
|
||||
';
|
||||
|
||||
$html2 = '<p>
|
||||
<font color="#ff0000">
|
||||
100°C is a hot temperature
|
||||
</font>
|
||||
<br>
|
||||
<font color="#0080ff">
|
||||
10°F is cold
|
||||
</font>
|
||||
</p>';
|
||||
|
||||
$html3 = '2<sup>3</sup> equals 8';
|
||||
|
||||
$html4 = 'H<sub>2</sub>SO<sub>4</sub> is the chemical formula for Sulphuric acid';
|
||||
|
||||
$html5 = '<strong>bold</strong>, <em>italic</em>, <strong><em>bold+italic</em></strong>';
|
||||
|
||||
$wizard = new \PHPExcel\Helper\HTML;
|
||||
$richText = $wizard->toRichTextObject($html1);
|
||||
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('A1', $richText);
|
||||
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getColumnDimension('A')
|
||||
->setWidth(48);
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getRowDimension(1)
|
||||
->setRowHeight(-1);
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1')
|
||||
->getAlignment()
|
||||
->setWrapText(true);
|
||||
|
||||
$richText = $wizard->toRichTextObject($html2);
|
||||
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setCellValue('A2', $richText);
|
||||
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getRowDimension(1)
|
||||
->setRowHeight(-1);
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->getStyle('A2')
|
||||
->getAlignment()
|
||||
->setWrapText(true);
|
||||
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A3', $wizard->toRichTextObject($html3));
|
||||
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A4', $wizard->toRichTextObject($html4));
|
||||
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A5', $wizard->toRichTextObject($html5));
|
||||
|
||||
|
||||
// Rename worksheet
|
||||
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||
$objPHPExcel->getActiveSheet()
|
||||
->setTitle('Rich Text Examples');
|
||||
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Save Excel 95 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load MergeBook1 from Excel2007 file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objPHPExcel1 = \PHPExcel\IOFactory::load(dirname(__FILE__) . "/templates/43mergeBook1.xlsx");
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Mergebook1 was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load MergeBook2 from Excel2007 file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objPHPExcel2 = \PHPExcel\IOFactory::load(dirname(__FILE__) . "/templates/43mergeBook2.xlsx");
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Mergebook2 was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
foreach($objPHPExcel2->getSheetNames() as $sheetName) {
|
||||
$sheet = $objPHPExcel2->getSheetByName($sheetName);
|
||||
$sheet->setTitle($sheet->getTitle() . ' copied');
|
||||
$objPHPExcel1->addExternalSheet($sheet);
|
||||
}
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel1, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , EOL;
|
||||
echo 'File has been created in ' , getcwd() , EOL;
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once dirname(__FILE__) . '/../src/Bootstrap.php';
|
||||
|
||||
if (!file_exists("05featuredemo.xlsx")) {
|
||||
exit("Please run 05featuredemo.php first." . EOL);
|
||||
}
|
||||
|
||||
$inputFileName = "05featuredemo.xlsx";
|
||||
$inputFileType = \PHPExcel\IOFactory::identify($inputFileName);
|
||||
$objReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
$sheetList = $objReader->listWorksheetNames($inputFileName);
|
||||
$sheetInfo = $objReader->listWorksheetInfo($inputFileName);
|
||||
|
||||
echo 'File Type:', PHP_EOL;
|
||||
var_dump($inputFileType);
|
||||
|
||||
echo 'Worksheet Names:', PHP_EOL;
|
||||
var_dump($sheetList);
|
||||
|
||||
echo 'Worksheet Names:', PHP_EOL;
|
||||
var_dump($sheetInfo);
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** \PHPExcel\IOFactory */
|
||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load from Excel2003XML file" , PHP_EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader('Excel2003XML');
|
||||
$objPHPExcel = $objReader->load("Excel2003XMLTest.xml");
|
||||
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel5 format" , PHP_EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', __FILE__) , PHP_EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
File diff suppressed because one or more lines are too long
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** \PHPExcel\IOFactory */
|
||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
echo date('H:i:s') , " Load from Gnumeric file" , PHP_EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader('Gnumeric');
|
||||
$objPHPExcel = $objReader->load("GnumericTest.gnumeric");
|
||||
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** \PHPExcel\IOFactory */
|
||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
echo date('H:i:s') , " Load from OOCalc file" , PHP_EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader('OOCalc');
|
||||
$objPHPExcel = $objReader->load("OOCalcTest.ods");
|
||||
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** \PHPExcel\IOFactory */
|
||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
// Use PCLZip rather than ZipArchive to read the Excel2007 OfficeOpenXML file
|
||||
PHPExcel\Settings::setZipClass(PHPExcel\Settings::PCLZIP);
|
||||
|
||||
echo date('H:i:s') , " Load from OOCalc file" , PHP_EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objReader = \PHPExcel\IOFactory::createReader('OOCalc');
|
||||
$objPHPExcel = $objReader->load("OOCalcTest.ods");
|
||||
|
||||
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , PHP_EOL;
|
||||
// Echo memory usage
|
||||
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Quadratic Equation Solver</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
/** Error reporting **/
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/');
|
||||
|
||||
?>
|
||||
<h1>Quadratic Equation Solver</h1>
|
||||
<form action="Quadratic.php" method="POST">
|
||||
Enter the coefficients for the Ax<sup>2</sup> + Bx + C = 0
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td><b>A </b></td>
|
||||
<td><input name="A" type="text" size="8" value="<?php echo (isset($_POST['A'])) ? htmlentities($_POST['A']) : ''; ?>"></td>
|
||||
</tr>
|
||||
<tr><td><b>B </b></td>
|
||||
<td><input name="B" type="text" size="8" value="<?php echo (isset($_POST['B'])) ? htmlentities($_POST['B']) : ''; ?>"></td>
|
||||
</tr>
|
||||
<tr><td><b>C </b></td>
|
||||
<td><input name="C" type="text" size="8" value="<?php echo (isset($_POST['C'])) ? htmlentities($_POST['C']) : ''; ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input name="submit" type="submit" value="calculate"><br />
|
||||
If A=0, the equation is not quadratic.
|
||||
</form>
|
||||
|
||||
<?php
|
||||
/** If the user has submitted the form, then we need to execute a calculation **/
|
||||
if (isset($_POST['submit'])) {
|
||||
if ($_POST['A'] == 0) {
|
||||
echo 'The equation is not quadratic';
|
||||
} else {
|
||||
/** So we include PHPExcel to perform the calculations **/
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
/** Load the quadratic equation solver worksheet into memory **/
|
||||
$objPHPExcel = \PHPExcel\IOFactory::load('./Quadratic.xlsx');
|
||||
|
||||
/** Set our A, B and C values **/
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', $_POST['A']);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', $_POST['B']);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', $_POST['C']);
|
||||
|
||||
|
||||
/** Calculate and Display the results **/
|
||||
echo '<hr /><b>Roots:</b><br />';
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
echo $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue().'<br />';
|
||||
echo $objPHPExcel->getActiveSheet()->getCell('B6')->getCalculatedValue().'<br />';
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />';
|
||||
echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
<html>
|
Binary file not shown.
|
@ -1,65 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Quadratic Equation Solver</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
/** Error reporting **/
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/');
|
||||
|
||||
?>
|
||||
<h1>Quadratic Equation Solver</h1>
|
||||
<form action="Quadratic2.php" method="POST">
|
||||
Enter the coefficients for the Ax<sup>2</sup> + Bx + C = 0
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td><b>A </b></td>
|
||||
<td><input name="A" type="text" size="8" value="<?php echo (isset($_POST['A'])) ? htmlentities($_POST['A']) : ''; ?>"></td>
|
||||
</tr>
|
||||
<tr><td><b>B </b></td>
|
||||
<td><input name="B" type="text" size="8" value="<?php echo (isset($_POST['B'])) ? htmlentities($_POST['B']) : ''; ?>"></td>
|
||||
</tr>
|
||||
<tr><td><b>C </b></td>
|
||||
<td><input name="C" type="text" size="8" value="<?php echo (isset($_POST['C'])) ? htmlentities($_POST['C']) : ''; ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input name="submit" type="submit" value="calculate"><br />
|
||||
If A=0, the equation is not quadratic.
|
||||
</form>
|
||||
|
||||
<?php
|
||||
/** If the user has submitted the form, then we need to execute a calculation **/
|
||||
if (isset($_POST['submit'])) {
|
||||
if ($_POST['A'] == 0) {
|
||||
echo 'The equation is not quadratic';
|
||||
} else {
|
||||
/** So we include PHPExcel to perform the calculations **/
|
||||
include 'PHPExcel/Calculation.php';
|
||||
|
||||
/** Calculate and Display the results **/
|
||||
echo '<hr /><b>Roots:</b><br />';
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
$discriminantFormula = '=POWER('.$_POST['B'].',2) - (4 * '.$_POST['A'].' * '.$_POST['C'].')';
|
||||
$discriminant = PHPExcel_Calculation::getInstance()->calculateFormula($discriminantFormula);
|
||||
|
||||
$r1Formula = '=IMDIV(IMSUM(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].')';
|
||||
$r2Formula = '=IF('.$discriminant.'=0,"Only one root",IMDIV(IMSUB(-'.$_POST['B'].',IMSQRT('.$discriminant.')),2 * '.$_POST['A'].'))';
|
||||
|
||||
echo PHPExcel_Calculation::getInstance()->calculateFormula($r1Formula).'<br />';
|
||||
echo PHPExcel_Calculation::getInstance()->calculateFormula($r2Formula).'<br />';
|
||||
$callEndTime = microtime(true);
|
||||
$callTime = $callEndTime - $callStartTime;
|
||||
|
||||
echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />';
|
||||
echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
<html>
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** \PHPExcel\IOFactory */
|
||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load from SYLK file" , PHP_EOL;
|
||||
$objPHPExcel = \PHPExcel\IOFactory::load("SylkTest.slk");
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
/** \PHPExcel\IOFactory */
|
||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
echo date('H:i:s') , " Load from XML file" , PHP_EOL;
|
||||
$inputFileName = "XMLTest.xml";
|
||||
|
||||
/** Identify the type of $inputFileName **/
|
||||
$inputFileType = \PHPExcel\IOFactory::identify($inputFileName);
|
||||
echo 'Loading ' , $inputFileName , ' using ' , $inputFileType , " Reader" , PHP_EOL;
|
||||
|
||||
/** Create a new Reader of the type that has been identified **/
|
||||
$objReader = \PHPExcel\IOFactory::createReader($inputFileType);
|
||||
/** Load $inputFileName to a PHPExcel Object **/
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , PHP_EOL;
|
||||
$objWriter = \PHPExcel\IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', __FILE__) , PHP_EOL;
|
||||
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing file" , PHP_EOL;
|
|
@ -1,450 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<?mso-application progid="Excel.Sheet"?>
|
||||
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:x="urn:schemas-microsoft-com:office:excel"
|
||||
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40">
|
||||
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
|
||||
<Title>Excel 2003 XML Test Workbook</Title>
|
||||
<Subject>This is a test workbook saved as Excel 2003 XML</Subject>
|
||||
<Author>Mark Baker</Author>
|
||||
<Keywords>PHPExcel Excel 2003 XML Reader</Keywords>
|
||||
<Description>This is a test for the PHPExcel Reader for workbooks saved using Excel 2003's XML Format</Description>
|
||||
<LastAuthor>Mark Baker</LastAuthor>
|
||||
<Created>2009-09-11T08:26:08Z</Created>
|
||||
<LastSaved>2009-09-17T22:53:09Z</LastSaved>
|
||||
<Category>Reader</Category>
|
||||
<Company>PHPExcel</Company>
|
||||
<Version>14.00</Version>
|
||||
</DocumentProperties>
|
||||
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
|
||||
<AllowPNG/>
|
||||
</OfficeDocumentSettings>
|
||||
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<WindowHeight>13176</WindowHeight>
|
||||
<WindowWidth>28452</WindowWidth>
|
||||
<WindowTopX>240</WindowTopX>
|
||||
<WindowTopY>516</WindowTopY>
|
||||
<ProtectStructure>False</ProtectStructure>
|
||||
<ProtectWindows>False</ProtectWindows>
|
||||
</ExcelWorkbook>
|
||||
<Styles>
|
||||
<Style ss:ID="Default" ss:Name="Normal">
|
||||
<Alignment ss:Vertical="Bottom"/>
|
||||
<Borders/>
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000"/>
|
||||
<Interior/>
|
||||
<NumberFormat/>
|
||||
<Protection/>
|
||||
</Style>
|
||||
<Style ss:ID="m42221568">
|
||||
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#00B050"/>
|
||||
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#0070C0"/>
|
||||
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#FFFF00"/>
|
||||
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#FF0000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s62">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#FF0000" ss:Bold="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s63">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s64">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000" ss:Bold="1"
|
||||
ss:Italic="1" ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s65">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000" ss:Bold="1"
|
||||
ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s66">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>
|
||||
<Interior/>
|
||||
</Style>
|
||||
<Style ss:ID="s67">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
<Interior/>
|
||||
</Style>
|
||||
<Style ss:ID="s68">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s69">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000" ss:Bold="1"
|
||||
ss:Italic="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s70">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000" ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s71">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000" ss:Italic="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s72">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="Short Date"/>
|
||||
</Style>
|
||||
<Style ss:ID="s73">
|
||||
<Borders>
|
||||
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s74">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="#\ ?/?"/>
|
||||
</Style>
|
||||
<Style ss:ID="s75">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s76">
|
||||
<Borders>
|
||||
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s77">
|
||||
<Borders>
|
||||
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s85">
|
||||
<Borders>
|
||||
<Border ss:Position="DiagonalLeft" ss:LineStyle="Double" ss:Weight="3"
|
||||
ss:Color="#FF0000"/>
|
||||
<Border ss:Position="DiagonalRight" ss:LineStyle="Double" ss:Weight="3"
|
||||
ss:Color="#FF0000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s86">
|
||||
<Alignment ss:Horizontal="Center" ss:Vertical="Bottom" ss:WrapText="1"/>
|
||||
<Font ss:FontName="Arial" ss:Size="12" ss:Color="#000000" ss:Bold="1"
|
||||
ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s87">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="0.00;[Red]0.00"/>
|
||||
</Style>
|
||||
<Style ss:ID="s88">
|
||||
<Font ss:FontName="Arial" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="dd\-mmm\-yyyy"/>
|
||||
</Style>
|
||||
</Styles>
|
||||
<Worksheet ss:Name="Sample Data">
|
||||
<Table ss:ExpandedColumnCount="10" ss:ExpandedRowCount="20" x:FullColumns="1"
|
||||
x:FullRows="1" ss:DefaultRowHeight="15">
|
||||
<Column ss:AutoFitWidth="0" ss:Width="90.6"/>
|
||||
<Column ss:Index="4" ss:AutoFitWidth="0" ss:Width="33.6"/>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s62"><Data ss:Type="String">Test String 1</Data></Cell>
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="Number">1</Data></Cell>
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="Number">5</Data></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s64"><Data ss:Type="String">A</Data></Cell>
|
||||
<Cell ss:StyleID="s65"><Data ss:Type="String">E</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">6</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">AE</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s66"><Data ss:Type="String">Test - String 2</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">2</Data></Cell>
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="Number">6</Data></Cell>
|
||||
<Cell ss:Index="5"><Data ss:Type="String">B</Data></Cell>
|
||||
<Cell><Data ss:Type="String">F</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">8</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">BF</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s67"><Data ss:Type="String">Test #3</Data></Cell>
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="Number">3</Data></Cell>
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="Number">7</Data></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s68"><Data ss:Type="String">C</Data></Cell>
|
||||
<Cell ss:StyleID="s69"><Data ss:Type="String">G</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">10</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">CG</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s70"><Data ss:Type="String">Test with (") in string</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">4</Data></Cell>
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="Number">8</Data></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s71"><Data ss:Type="String">D</Data></Cell>
|
||||
<Cell><Data ss:Type="String">H</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">12</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">DH</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="8" ss:Formula="=SUM(R[-4]C[-6]:R[-1]C[-6])"><Data
|
||||
ss:Type="Number">10</Data></Cell>
|
||||
<Cell ss:Formula="=SUM(R[-4]C[-6]:R[-1]C[-6])"><Data ss:Type="Number">26</Data></Cell>
|
||||
<Cell ss:Formula="=SUM(R[-4]C[-8]:R[-1]C[-7])"><Data ss:Type="Number">36</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="2"><Data ss:Type="Number">1.23</Data></Cell>
|
||||
<Cell><Data ss:Type="Boolean">1</Data></Cell>
|
||||
<Cell ss:StyleID="s72"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="2"><Data ss:Type="Number">2.34</Data></Cell>
|
||||
<Cell><Data ss:Type="Boolean">0</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="2"><Data ss:Type="Number">3.45</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5"/>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s72"><Data ss:Type="DateTime">1960-12-19T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="3" ss:StyleID="s73"><Data ss:Type="String">TOP</Data></Cell>
|
||||
<Cell ss:Index="7" ss:Formula="=#N/A"><Data ss:Type="Error">#N/A</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s74"><Data ss:Type="Number">1.5</Data></Cell>
|
||||
<Cell ss:Index="7" ss:Formula="=12/0"><Data ss:Type="Error">#DIV/0!</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5">
|
||||
<Cell ss:Index="3" ss:StyleID="s75"><Data ss:Type="String">BOTTOM</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:Index="14" ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="3" ss:StyleID="s76"><Data ss:Type="String">LEFT</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:Index="16" ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="3" ss:StyleID="s77"><Data ss:Type="String">RIGHT</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5">
|
||||
<Cell ss:Index="2" ss:MergeAcross="1" ss:MergeDown="1" ss:StyleID="m42221568"><Data
|
||||
ss:Type="String">BOX</Data></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s85"/>
|
||||
<Cell ss:Index="7"><Data ss:Type="String">Test Column 1</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="8"><Data ss:Type="String">Test Column 2</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:Index="9"><Data ss:Type="String">Test Column 3</Data></Cell>
|
||||
</Row>
|
||||
</Table>
|
||||
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<PageSetup>
|
||||
<Header x:Margin="0.3"/>
|
||||
<Footer x:Margin="0.3"/>
|
||||
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
|
||||
</PageSetup>
|
||||
<Unsynced/>
|
||||
<Print>
|
||||
<ValidPrinterInfo/>
|
||||
<HorizontalResolution>600</HorizontalResolution>
|
||||
<VerticalResolution>600</VerticalResolution>
|
||||
</Print>
|
||||
<Selected/>
|
||||
<Panes>
|
||||
<Pane>
|
||||
<Number>3</Number>
|
||||
<ActiveRow>17</ActiveRow>
|
||||
<ActiveCol>4</ActiveCol>
|
||||
</Pane>
|
||||
</Panes>
|
||||
<ProtectObjects>False</ProtectObjects>
|
||||
<ProtectScenarios>False</ProtectScenarios>
|
||||
<AllowFormatCells/>
|
||||
<AllowSizeCols/>
|
||||
<AllowSizeRows/>
|
||||
<AllowInsertCols/>
|
||||
<AllowInsertRows/>
|
||||
<AllowInsertHyperlinks/>
|
||||
<AllowDeleteCols/>
|
||||
<AllowDeleteRows/>
|
||||
<AllowSort/>
|
||||
<AllowFilter/>
|
||||
<AllowUsePivotTables/>
|
||||
</WorksheetOptions>
|
||||
</Worksheet>
|
||||
<Worksheet ss:Name="Report Data">
|
||||
<Table ss:ExpandedColumnCount="7" ss:ExpandedRowCount="14" x:FullColumns="1"
|
||||
x:FullRows="1" ss:DefaultRowHeight="15">
|
||||
<Column ss:AutoFitWidth="0" ss:Width="66.600000000000009"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="68.399999999999991"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="62.400000000000006"/>
|
||||
<Column ss:Width="69.599999999999994"/>
|
||||
<Column ss:Index="6" ss:Width="69.599999999999994"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="64.8"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="31.5">
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Heading 1</Data></Cell>
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Heading 2</Data></Cell>
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Third Heading</Data></Cell>
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Date Heading</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s86"><Data ss:Type="String">Adjusted Date</Data></Cell>
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Adjusted Number</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">ABC</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">1</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">1.1100000000000001</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2001-01-01T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2000-12-31T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">1.1100000000000001</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">BCD</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">2</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">2.2200000000000002</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2002-02-02T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2002-01-31T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">4.4400000000000004</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">CDE</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">3</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">3.33</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2003-03-03T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2003-02-28T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">9.99</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">DEF</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">4</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">4.4400000000000004</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2004-04-03T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2004-03-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">17.760000000000002</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">EFG</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">5</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">5.55</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2005-05-04T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2005-04-29T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">27.75</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">FGH</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">6</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">6.66</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2006-06-05T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2006-05-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">39.96</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">GHI</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">7</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">7.77</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2007-07-06T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2007-06-29T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">54.39</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">HIJ</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">8</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">8.8800000000000008</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2008-08-07T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2008-07-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">71.040000000000006</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">IJK</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">9</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">9.99</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2009-09-08T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2009-08-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">89.91</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">JKL</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">10</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">11.1</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2010-10-09T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2010-09-29T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">111</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">KLM</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">11</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">12.21</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2011-11-11T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2011-10-31T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">134.31</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">LMN</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">12</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">13.32</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">2012-12-12T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">2012-11-30T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">159.84</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell><Data ss:Type="String">ZYX</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">-1</Data></Cell>
|
||||
<Cell ss:StyleID="s87"><Data ss:Type="Number">-1.1100000000000001</Data></Cell>
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="DateTime">1999-12-01T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="6" ss:StyleID="s88" ss:Formula="=RC[-2]-RC[-4]"><Data
|
||||
ss:Type="DateTime">1999-12-02T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s87" ss:Formula="=RC[-5]*RC[-4]"><Data ss:Type="Number">1.1100000000000001</Data></Cell>
|
||||
</Row>
|
||||
</Table>
|
||||
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<PageSetup>
|
||||
<Header x:Margin="0.3"/>
|
||||
<Footer x:Margin="0.3"/>
|
||||
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
|
||||
</PageSetup>
|
||||
<Unsynced/>
|
||||
<Print>
|
||||
<ValidPrinterInfo/>
|
||||
<HorizontalResolution>600</HorizontalResolution>
|
||||
<VerticalResolution>600</VerticalResolution>
|
||||
</Print>
|
||||
<ProtectObjects>False</ProtectObjects>
|
||||
<ProtectScenarios>False</ProtectScenarios>
|
||||
<AllowFormatCells/>
|
||||
<AllowSizeCols/>
|
||||
<AllowSizeRows/>
|
||||
<AllowInsertCols/>
|
||||
<AllowInsertRows/>
|
||||
<AllowInsertHyperlinks/>
|
||||
<AllowDeleteCols/>
|
||||
<AllowDeleteRows/>
|
||||
<AllowSort/>
|
||||
<AllowFilter/>
|
||||
<AllowUsePivotTables/>
|
||||
</WorksheetOptions>
|
||||
<ConditionalFormatting xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<Range>R2C3:R14C3</Range>
|
||||
<Condition>
|
||||
<Qualifier>Greater</Qualifier>
|
||||
<Value1>0</Value1>
|
||||
<Format Style='color:#006100;background:#C6EFCE'/>
|
||||
</Condition>
|
||||
<Condition>
|
||||
<Qualifier>Less</Qualifier>
|
||||
<Value1>0</Value1>
|
||||
<Format Style='color:#9C0006;background:#FFC7CE'/>
|
||||
</Condition>
|
||||
</ConditionalFormatting>
|
||||
</Worksheet>
|
||||
</Workbook>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue