Advertisement
pipook

PHPExcel

Jul 31st, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2. require_once('../../../../includes.php');
  3. require_once PATH_CLASS.DS.'PHPExcel.php';
  4. require_once PATH_CLASS.DS.'PHPExcel'.DS.'Writer'.DS.'Excel5.php';
  5. require_once PATH_CLASS.DS.'PHPExcel'.DS.'IOFactory.php';
  6. // Crea un nuevo objeto PHPExcel
  7. $objPHPExcel = new PHPExcel();
  8.  
  9. // Set document properties
  10. $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
  11.                  ->setLastModifiedBy("Maarten Balliauw")
  12.                  ->setTitle("Office 2007 XLSX Test Document")
  13.                  ->setSubject("Office 2007 XLSX Test Document")
  14.                  ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
  15.                  ->setKeywords("office 2007 openxml php")
  16.                  ->setCategory("Test result file");
  17.  
  18.  
  19. // Add some data
  20. $objPHPExcel->setActiveSheetIndex(0)
  21.             ->setCellValue('A1', 'Hello')
  22.             ->setCellValue('B2', 'world!')
  23.             ->setCellValue('C1', 'Hello')
  24.             ->setCellValue('D2', 'world!');
  25.  
  26. // Miscellaneous glyphs, UTF-8
  27. $objPHPExcel->setActiveSheetIndex(0)
  28.             ->setCellValue('A4', 'Miscellaneous glyphs')
  29.             ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
  30.  
  31. // Rename worksheet
  32. $objPHPExcel->getActiveSheet()->setTitle('Simple');
  33.  
  34.  
  35. // Set active sheet index to the first sheet, so Excel opens this as the first sheet
  36. $objPHPExcel->setActiveSheetIndex(0);
  37.  
  38.  
  39. // Redirect output to a client’s web browser (Excel5)
  40. header('Content-Type: application/vnd.ms-excel');
  41. header('Content-Disposition: attachment;filename="01simple.xls"');
  42. header('Cache-Control: max-age=0');
  43.  
  44. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  45. $objWriter->save('php://output');
  46. exit;
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement