1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| $xls_service = $this->get('xls.service_xls5');
$xls_service->excelObj->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2005 XLSX Test Document")
->setSubject("Office 2005 XLSX Test Document")
->setDescription("Test document for Office 2005 XLSX, generated using PHP classes.")
->setKeywords("office 2005 openxml php")
->setCategory("Test result file");
$xls_service->excelObj->setActiveSheetIndex(0)
->setCellValue('A1', 'id')
->setCellValue('B1', 'titre');
$xls_service->excelObj->setActiveSheetIndex(0)
->setCellValue("A1", '1')
->setCellValue("B1", 'foobar');
$xls_service->excelObj->getActiveSheet()->setTitle('Simple');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$xls_service->excelObj->setActiveSheetIndex(0);
//create the response
$response = $xls_service->getResponse();
$response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
$response->headers->set('Content-Disposition', 'attachment;filename=File_'. \date('d-m-Y') .'.xls');
return $response; |
Partager