"Fossies" - the Fresh Open Source Software Archive

Member "ILIAS-5.4.8/libs/composer/vendor/phpoffice/phpspreadsheet/samples/Basic/01_Simple_download_ods.php" (22 Nov 2019, 2123 Bytes) of package /linux/www/ILIAS-5.4.8.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. For more information about "01_Simple_download_ods.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 use PhpOffice\PhpSpreadsheet\Helper\Sample;
    4 use PhpOffice\PhpSpreadsheet\IOFactory;
    5 use PhpOffice\PhpSpreadsheet\Spreadsheet;
    6 
    7 require_once __DIR__ . '/../../src/Bootstrap.php';
    8 
    9 $helper = new Sample();
   10 if ($helper->isCli()) {
   11     $helper->log('This example should only be run from a Web Browser' . PHP_EOL);
   12 
   13     return;
   14 }
   15 
   16 // Create new Spreadsheet object
   17 $spreadsheet = new Spreadsheet();
   18 
   19 // Set document properties
   20 $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
   21     ->setLastModifiedBy('Maarten Balliauw')
   22     ->setTitle('Office 2007 XLSX Test Document')
   23     ->setSubject('Office 2007 XLSX Test Document')
   24     ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
   25     ->setKeywords('office 2007 openxml php')
   26     ->setCategory('Test result file');
   27 
   28 // Add some data
   29 $spreadsheet->setActiveSheetIndex(0)
   30     ->setCellValue('A1', 'Hello')
   31     ->setCellValue('B2', 'world!')
   32     ->setCellValue('C1', 'Hello')
   33     ->setCellValue('D2', 'world!');
   34 
   35 // Miscellaneous glyphs, UTF-8
   36 $spreadsheet->setActiveSheetIndex(0)
   37     ->setCellValue('A4', 'Miscellaneous glyphs')
   38     ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
   39 
   40 // Rename worksheet
   41 $spreadsheet->getActiveSheet()->setTitle('Simple');
   42 
   43 // Set active sheet index to the first sheet, so Excel opens this as the first sheet
   44 $spreadsheet->setActiveSheetIndex(0);
   45 
   46 // Redirect output to a client’s web browser (Ods)
   47 header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
   48 header('Content-Disposition: attachment;filename="01simple.ods"');
   49 header('Cache-Control: max-age=0');
   50 // If you're serving to IE 9, then the following may be needed
   51 header('Cache-Control: max-age=1');
   52 
   53 // If you're serving to IE over SSL, then the following may be needed
   54 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
   55 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
   56 header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
   57 header('Pragma: public'); // HTTP/1.0
   58 
   59 $writer = IOFactory::createWriter($spreadsheet, 'Ods');
   60 $writer->save('php://output');
   61 exit;