Special Feature: (kkamkou) Phar builder script to add phar file as a distribution option
This commit is contained in:
parent
960f5a32a2
commit
dc01c8bbc1
|
@ -1,3 +1,4 @@
|
|||
build/PHPExcel.phar
|
||||
unitTests/codeCoverage
|
||||
|
||||
*.buildpath
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 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 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
# required: PHP 5.3+ and zlib extension
|
||||
|
||||
// ini option check
|
||||
if (ini_get('phar.readonly')) {
|
||||
echo "php.ini: set the 'phar.readonly' option to 0 to enable phar creation\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// output name
|
||||
$pharName = 'PHPExcel.phar';
|
||||
|
||||
// target folder
|
||||
$sourceDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Classes' . DIRECTORY_SEPARATOR;
|
||||
|
||||
// default meta information
|
||||
$metaData = array(
|
||||
'Author' => 'Mark Baker <mbaker@inviqa.com>',
|
||||
'Description' => 'A pure PHP library for reading and writing spreadsheet files',
|
||||
'Copyright' => 'Mark Baker (c) 2006-' . date('Y'),
|
||||
'Timestamp' => time(),
|
||||
'Version' => '##VERSION##',
|
||||
'Date' => '##DATE##'
|
||||
);
|
||||
|
||||
// cleanup
|
||||
if (file_exists($pharName)) {
|
||||
echo "Removed: {$pharName}\n";
|
||||
unlink($pharName);
|
||||
}
|
||||
|
||||
echo "Building...\n";
|
||||
|
||||
// the phar object
|
||||
$phar = new Phar($pharName, null, 'PHPExcel');
|
||||
$phar->buildFromDirectory($sourceDir);
|
||||
$phar->setStub(
|
||||
<<<'EOT'
|
||||
<?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();
|
||||
EOT
|
||||
);
|
||||
$phar->setMetadata($metaData);
|
||||
$phar->compressFiles(Phar::GZ);
|
||||
|
||||
echo "Complete.\n";
|
||||
|
||||
exit();
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (C) 2006 - 2012 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 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @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();
|
||||
|
||||
// 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;
|
||||
$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;
|
|
@ -72,6 +72,7 @@ The following methods will be changed in version 1.7.9
|
|||
|
||||
|
||||
Fixed in develop branch:
|
||||
- Special: (kkamkou) Phar builder script to add phar file as a distribution option
|
||||
- Feature: (MBaker) Refactor PDF Writer to allow use with a choice of PDF Rendering library
|
||||
rather than restricting to tcPDF
|
||||
Current options are tcPDF, mPDF, DomPDF
|
||||
|
|
Loading…
Reference in New Issue