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.

104 lines
3.5 KiB

  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2015 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel
  23. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /** Error reporting */
  28. error_reporting(E_ALL);
  29. ini_set('display_errors', TRUE);
  30. ini_set('display_startup_errors', TRUE);
  31. date_default_timezone_set('Europe/London');
  32. if (PHP_SAPI == 'cli')
  33. die('This example should only be run from a Web Browser');
  34. /** Include PHPExcel */
  35. require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
  36. // Change these values to select the Rendering library that you wish to use
  37. // and its directory location on your server
  38. //$rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
  39. $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
  40. //$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
  41. //$rendererLibrary = 'tcPDF5.9';
  42. $rendererLibrary = 'mPDF5.4';
  43. //$rendererLibrary = 'domPDF0.6.0beta3';
  44. $rendererLibraryPath = dirname(__FILE__).'/../../../libraries/PDF/' . $rendererLibrary;
  45. // Create new PHPExcel object
  46. $objPHPExcel = new PHPExcel();
  47. // Set document properties
  48. $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
  49. ->setLastModifiedBy("Maarten Balliauw")
  50. ->setTitle("PDF Test Document")
  51. ->setSubject("PDF Test Document")
  52. ->setDescription("Test document for PDF, generated using PHP classes.")
  53. ->setKeywords("pdf php")
  54. ->setCategory("Test result file");
  55. // Add some data
  56. $objPHPExcel->setActiveSheetIndex(0)
  57. ->setCellValue('A1', 'Hello')
  58. ->setCellValue('B2', 'world!')
  59. ->setCellValue('C1', 'Hello')
  60. ->setCellValue('D2', 'world!');
  61. // Miscellaneous glyphs, UTF-8
  62. $objPHPExcel->setActiveSheetIndex(0)
  63. ->setCellValue('A4', 'Miscellaneous glyphs')
  64. ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
  65. // Rename worksheet
  66. $objPHPExcel->getActiveSheet()->setTitle('Simple');
  67. $objPHPExcel->getActiveSheet()->setShowGridLines(false);
  68. // Set active sheet index to the first sheet, so Excel opens this as the first sheet
  69. $objPHPExcel->setActiveSheetIndex(0);
  70. if (!PHPExcel_Settings::setPdfRenderer(
  71. $rendererName,
  72. $rendererLibraryPath
  73. )) {
  74. die(
  75. 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
  76. '<br />' .
  77. 'at the top of this script as appropriate for your directory structure'
  78. );
  79. }
  80. // Redirect output to a client’s web browser (PDF)
  81. header('Content-Type: application/pdf');
  82. header('Content-Disposition: attachment;filename="01simple.pdf"');
  83. header('Cache-Control: max-age=0');
  84. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
  85. $objWriter->save('php://output');
  86. exit;