예제 #1
0
 * @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;
            }
        }
    }
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()) . '"';
예제 #3
0
 * 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 (http://www.codeplex.com/PHPExcel)
 * @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;
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2015 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);
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;
예제 #5
0
 * 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 (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);
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;
예제 #6
0
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