For God so loved the world, that He gave His only begotten Son, that all who believe in Him should not perish but have everlasting life
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.6 KiB

  1. <?php
  2. /** Error reporting */
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', TRUE);
  5. ini_set('display_startup_errors', TRUE);
  6. date_default_timezone_set('Europe/London');
  7. define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
  8. date_default_timezone_set('Europe/London');
  9. /**
  10. * PHPExcel
  11. *
  12. * Copyright (c) 2006 - 2015 PHPExcel
  13. *
  14. * This library is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU Lesser General Public
  16. * License as published by the Free Software Foundation; either
  17. * version 2.1 of the License, or (at your option) any later version.
  18. *
  19. * This library is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * Lesser General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Lesser General Public
  25. * License along with this library; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  27. *
  28. * @category PHPExcel
  29. * @package PHPExcel
  30. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  31. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  32. * @version ##VERSION##, ##DATE##
  33. */
  34. /** PHPExcel */
  35. require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
  36. if (!file_exists("33chartcreate-bar.xlsx")) {
  37. exit("Please run 33chartcreate-bar.php first." . EOL);
  38. }
  39. echo date('H:i:s') , " Load from Excel2007 file" , EOL;
  40. $objReader = PHPExcel_IOFactory::createReader("Excel2007");
  41. $objReader->setIncludeCharts(TRUE);
  42. $objPHPExcel = $objReader->load("33chartcreate-bar.xlsx");
  43. echo date('H:i:s') , " Update cell data values that are displayed in the chart" , EOL;
  44. $objWorksheet = $objPHPExcel->getActiveSheet();
  45. $objWorksheet->fromArray(
  46. array(
  47. array(50-12, 50-15, 50-21),
  48. array(50-56, 50-73, 50-86),
  49. array(50-52, 50-61, 50-69),
  50. array(50-30, 50-32, 50),
  51. ),
  52. NULL,
  53. 'B2'
  54. );
  55. // Save Excel 2007 file
  56. echo date('H:i:s') , " Write to Excel2007 format" , EOL;
  57. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  58. $objWriter->setIncludeCharts(TRUE);
  59. $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
  60. echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
  61. // Echo memory peak usage
  62. echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
  63. // Echo done
  64. echo date('H:i:s') , " Done writing file" , EOL;
  65. echo 'File has been created in ' , getcwd() , EOL;