37_Page_layout_view.php 1021 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  3. use PhpOffice\PhpSpreadsheet\Worksheet\SheetView;
  4. require __DIR__ . '/../Header.php';
  5. // Create new Spreadsheet object
  6. $helper->log('Create new Spreadsheet object');
  7. $spreadsheet = new Spreadsheet();
  8. // Set document properties
  9. $helper->log('Set document properties');
  10. $spreadsheet->getProperties()->setCreator('PHPOffice')
  11. ->setLastModifiedBy('PHPOffice')
  12. ->setTitle('PhpSpreadsheet Test Document')
  13. ->setSubject('PhpSpreadsheet Test Document')
  14. ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.')
  15. ->setKeywords('Office PhpSpreadsheet php')
  16. ->setCategory('Test result file');
  17. // Add some data
  18. $helper->log('Add some data');
  19. $spreadsheet->setActiveSheetIndex(0)
  20. ->setCellValue('A1', 'Hello')
  21. ->setCellValue('B2', 'world!');
  22. // Set the page layout view as page layout
  23. $spreadsheet->getActiveSheet()->getSheetView()->setView(SheetView::SHEETVIEW_PAGE_LAYOUT);
  24. // Save
  25. $helper->write($spreadsheet, __FILE__);