"; $objPHPExcel = new PHPExcel(); // Set properties echo date('H:i:s') . " Set properties
"; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Franklin") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file"); // Add some data echo date('H:i:s') . " Add some data
"; $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', 'Hello') ->setCellValue('B2', 'world!'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file echo date('H:i:s') . " Write to Excel2007 format
"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); // Save Excel5 file echo date('H:i:s') . " Write to Excel5 format
"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); // Echo memory peak usage echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r
"; // Echo done echo date('H:i:s') . " Done writing file.\r
"; unset($objWriter); echo '
'; // Create new PHPExcel object echo date('H:i:s') . " Create new PHPExcel object
"; $objPHPExcelRead = PHPExcel_IOFactory::load('31docproperties_write.xls'); // Set properties echo date('H:i:s') . " Get properties
"; echo 'Creator : '.$objPHPExcelRead->getProperties()->getCreator().'
'; echo 'LastModifiedBy : '.$objPHPExcelRead->getProperties()->getLastModifiedBy().'
'; echo 'Title : '.$objPHPExcelRead->getProperties()->getTitle().'
'; echo 'Subject : '.$objPHPExcelRead->getProperties()->getSubject().'
'; echo 'Description : '.$objPHPExcelRead->getProperties()->getDescription().'
'; echo 'Keywords : '.$objPHPExcelRead->getProperties()->getKeywords().'
'; echo 'Category : '.$objPHPExcelRead->getProperties()->getCategory().'
'; // Echo memory peak usage echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r
"; ?>