"Fossies" - the Fresh Open Source Software Archive

Member "ILIAS-5.4.9/libs/composer/vendor/phpoffice/phpspreadsheet/samples/Basic/01_Simple.php" (24 Jan 2020, 1839 Bytes) of package /linux/www/ILIAS-5.4.9.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.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 use PhpOffice\PhpSpreadsheet\Spreadsheet;
    4 
    5 require __DIR__ . '/../Header.php';
    6 
    7 $spreadsheet = new Spreadsheet();
    8 $helper->log('Create new Spreadsheet object');
    9 $spreadsheet = new Spreadsheet();
   10 
   11 // Set document properties
   12 $helper->log('Set document properties');
   13 $spreadsheet->getProperties()
   14     ->setCreator('Maarten Balliauw')
   15     ->setLastModifiedBy('Maarten Balliauw')
   16     ->setTitle('PhpSpreadsheet Test Document')
   17     ->setSubject('PhpSpreadsheet Test Document')
   18     ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
   19     ->setKeywords('office PhpSpreadsheet php')
   20     ->setCategory('Test result file');
   21 
   22 // Add some data
   23 $helper->log('Add some data');
   24 $spreadsheet->setActiveSheetIndex(0)
   25     ->setCellValue('A1', 'Hello')
   26     ->setCellValue('B2', 'world!')
   27     ->setCellValue('C1', 'Hello')
   28     ->setCellValue('D2', 'world!');
   29 
   30 // Miscellaneous glyphs, UTF-8
   31 $spreadsheet->setActiveSheetIndex(0)
   32     ->setCellValue('A4', 'Miscellaneous glyphs')
   33     ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
   34 
   35 $spreadsheet->getActiveSheet()
   36     ->setCellValue('A8', "Hello\nWorld");
   37 $spreadsheet->getActiveSheet()
   38     ->getRowDimension(8)
   39     ->setRowHeight(-1);
   40 $spreadsheet->getActiveSheet()
   41     ->getStyle('A8')
   42     ->getAlignment()
   43     ->setWrapText(true);
   44 
   45 $value = "-ValueA\n-Value B\n-Value C";
   46 $spreadsheet->getActiveSheet()
   47     ->setCellValue('A10', $value);
   48 $spreadsheet->getActiveSheet()
   49     ->getRowDimension(10)
   50     ->setRowHeight(-1);
   51 $spreadsheet->getActiveSheet()
   52     ->getStyle('A10')
   53     ->getAlignment()
   54     ->setWrapText(true);
   55 $spreadsheet->getActiveSheet()
   56     ->getStyle('A10')
   57     ->setQuotePrefix(true);
   58 
   59 // Rename worksheet
   60 $helper->log('Rename worksheet');
   61 $spreadsheet->getActiveSheet()
   62     ->setTitle('Simple');
   63 
   64 // Save
   65 $helper->write($spreadsheet, __FILE__);