"Fossies" - the Fresh Open Source Software Archive

Member "groupoffice-6.4.210-php-71/vendor/phpoffice/phpexcel/Examples/01simple-download-ods.php" (22 Nov 2018, 3289 Bytes) of package /linux/www/groupoffice-6.4.210-php-71.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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 
   28 /** Error reporting */
   29 error_reporting(E_ALL);
   30 ini_set('display_errors', TRUE);
   31 ini_set('display_startup_errors', TRUE);
   32 date_default_timezone_set('Europe/London');
   33 
   34 if (PHP_SAPI == 'cli')
   35     die('This example should only be run from a Web Browser');
   36 
   37 /** Include PHPExcel */
   38 require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
   39 
   40 
   41 // Create new PHPExcel object
   42 $objPHPExcel = new PHPExcel();
   43 
   44 // Set document properties
   45 $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
   46                              ->setLastModifiedBy("Maarten Balliauw")
   47                              ->setTitle("Office 2007 XLSX Test Document")
   48                              ->setSubject("Office 2007 XLSX Test Document")
   49                              ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
   50                              ->setKeywords("office 2007 openxml php")
   51                              ->setCategory("Test result file");
   52 
   53 
   54 // Add some data
   55 $objPHPExcel->setActiveSheetIndex(0)
   56             ->setCellValue('A1', 'Hello')
   57             ->setCellValue('B2', 'world!')
   58             ->setCellValue('C1', 'Hello')
   59             ->setCellValue('D2', 'world!');
   60 
   61 // Miscellaneous glyphs, UTF-8
   62 $objPHPExcel->setActiveSheetIndex(0)
   63             ->setCellValue('A4', 'Miscellaneous glyphs')
   64             ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
   65 
   66 // Rename worksheet
   67 $objPHPExcel->getActiveSheet()->setTitle('Simple');
   68 
   69 
   70 // Set active sheet index to the first sheet, so Excel opens this as the first sheet
   71 $objPHPExcel->setActiveSheetIndex(0);
   72 
   73 
   74 // Redirect output to a client’s web browser (OpenDocument)
   75 header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
   76 header('Content-Disposition: attachment;filename="01simple.ods"');
   77 header('Cache-Control: max-age=0');
   78 // If you're serving to IE 9, then the following may be needed
   79 header('Cache-Control: max-age=1');
   80 
   81 // If you're serving to IE over SSL, then the following may be needed
   82 header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
   83 header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
   84 header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
   85 header ('Pragma: public'); // HTTP/1.0
   86 
   87 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'OpenDocument');
   88 $objWriter->save('php://output');
   89 exit;