22_Heavily_formatted.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  3. use PhpOffice\PhpSpreadsheet\Style\Border;
  4. use PhpOffice\PhpSpreadsheet\Style\Fill;
  5. require __DIR__ . '/../Header.php';
  6. // Create new Spreadsheet object
  7. $helper->log('Create new Spreadsheet object');
  8. $spreadsheet = new Spreadsheet();
  9. // Set document properties
  10. $helper->log('Set document properties');
  11. $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
  12. ->setLastModifiedBy('Maarten Balliauw')
  13. ->setTitle('Office 2007 XLSX Test Document')
  14. ->setSubject('Office 2007 XLSX Test Document')
  15. ->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
  16. ->setKeywords('office 2007 openxml php')
  17. ->setCategory('Test result file');
  18. // Add some data
  19. $helper->log('Add some data');
  20. $spreadsheet->setActiveSheetIndex(0);
  21. $spreadsheet->getActiveSheet()->getStyle('A1:T100')->applyFromArray(
  22. ['fill' => [
  23. 'fillType' => Fill::FILL_SOLID,
  24. 'color' => ['argb' => 'FFCCFFCC'],
  25. ],
  26. 'borders' => [
  27. 'bottom' => ['borderStyle' => Border::BORDER_THIN],
  28. 'right' => ['borderStyle' => Border::BORDER_MEDIUM],
  29. ],
  30. ]
  31. );
  32. $spreadsheet->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
  33. ['fill' => [
  34. 'fillType' => Fill::FILL_SOLID,
  35. 'color' => ['argb' => 'FFFFFF00'],
  36. ],
  37. ]
  38. );
  39. // Save
  40. $helper->write($spreadsheet, __FILE__);