I use phpexcelBundle for export database to file excel but i have problem when I use attribut in databsae is null ,I have problem of export file excel ,I have problem attribut is null but when i use if before set cellule I have problem of export also this is problem :
[:error] [pid 2684] [client ::1:33360] PHP Parse error: syntax error, unexpected '$phpExcelObject' (T_VARIABLE), expecting function (T_FUNCTION) in /var/www/html/Projetsf/src/FrontBundle/Controller/StepsController.php on line 10000, referer:
this is code controller :
public function exportXLSAction($id){
$phpExcelObject = new PHPExcel();
$phpExcelObject->getProperties()->setCreator("liuggio")
->setLastModifiedBy("Giulio De Donato")
->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");
$em = $this->container->get('doctrine')->getManager($this->container->get('account_manager')->getCurrentAccount()->getEmname());
$Employee= $em->getRepository('FrontBundle:Employee')->findOneBy(array('id' =>$id));
if ($Employee->getNom() != null) { $x = $Employee->getNom(); } else { $x = ' '; }
$phpExcelObject->setActiveSheetIndex(0)
->setCellValue('A1', 'Civilité')
->setCellValue('A2', $Employee->getCivilite())
->setCellValue('B1','Nom')
->setCellValue('B2', $x)
->setCellValue('C1', 'Prénom')
->setCellValue('C2', $Employee->getPrenom())
->setCellValue('D1', 'Email Personnel')
->setCellValue('D2', $Employee->getEmail())
->setCellValue('E1', 'Adresse Personnel')
->setCellValue('E2', $Employee->getAdresse()) ;
foreach(range('A','Z') as $columnID){
}
}
$phpExcelObject->setActiveSheetIndex(0)->getColumnDimension($columnID)->setAutoSize(true);
}
foreach(range('A','Z') as $columnID){
$phpExcelObject->setActiveSheetIndex(0)->getColumnDimension('A'.$columnID)->setAutoSize(true);
}
$objWriter = new PHPExcel_Writer_Excel2007($phpExcelObject);
$nomfichier = $Employee->getPrenom().'.xlsx';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$nomfichier.'"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
// var_dump($response);
return new response('yes');
}
problem in test if $employee->getnom()!= null ... but i have make this test
help me for resolve this problem and thanks advanced