Created
May 9, 2014 18:48
-
-
Save hervehobbes/c510f5a0e9028b4b3d95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
$currentInclude = ini_get('include_path'); | |
ini_set('include_path', $currentInclude.";C:/dev/web/excel/Classes/"); | |
require_once 'PHPExcel.php'; | |
require_once 'PHPExcel/Writer/Excel2007.php'; | |
$objPHPExcel = new PHPExcel(); | |
// Set properties | |
echo date('H:i:s') . " Set properties\n"; | |
$objPHPExcel->getProperties()->setCreator("Bob Morane"); | |
$objPHPExcel->getProperties()->setLastModifiedBy("Bob Morane"); | |
$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document"); | |
$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document"); | |
$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); | |
// Add some data | |
echo date('H:i:s') . " Add some data\n"; | |
$objPHPExcel->setActiveSheetIndex(0); | |
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Hello'); | |
$objPHPExcel->getActiveSheet()->SetCellValue('A2', 'world!'); | |
$objPHPExcel->getActiveSheet()->SetCellValue('B1', 123); | |
$objPHPExcel->getActiveSheet()->SetCellValue('B2', 456); | |
// Rename sheet | |
//echo date('H:i:s') . " Rename sheet\n"; | |
$objPHPExcel->getActiveSheet()->setTitle('Mon test'); | |
// Save Excel 2007 file | |
echo date('H:i:s') . " Write to Excel2007 format\n"; | |
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); | |
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); | |
// Echo done | |
echo date('H:i:s') . " Done writing file.\r\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment