I am trying to get variables into a PHPExcel
file.
When I open the page without variables it shows me an excellent Excel document. Once I add the variables into the cells, the excel sheet turns white and returns nothing. I know it is possible to call variables into ExcelSheets
, I have no clue why it is not working.
Code:
// Add Data in your file
foreach ($response as $key => $value) {
$timestamp = substr($value['timestamp'], 6, 10);
$timestamp = date('d-m-Y H:i:s', $timestamp);
//Table
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('B2', 'Beller ')
->setCellValue('D2', 'Beller nummer')
->setCellValue('F2', 'Datum')
->setCellValue('H2', 'ontvanger naam')
->setCellValue('J2', 'ontvanger nummer')
->setCellValue('L2', 'Billing seconds')
->setCellValue('N2', 'Direction')
// array
->setCellValue('B3', $value ['caller_id_name'])
->setCellValue('D3', $value ['caller_id_number'])
->setCellValue('F3', $timestamp)
->setCellValue('H3', $value ['callee_id_name'])
->setCellValue('J3', $value ['callee_id_number'])
->setCellValue('L3', $value ['billing_seconds'])
->setCellValue('N3', $value ['direction']);
}
To clarify the situation: when I use the variables it returns an empty excel sheet (white screen).
When I try it without variables it returns me exactly what I want, but I want that this also work with my variable.
// Add Data in your file
//Werkt niet foreach ($response as $key => $value) {
//Werkt niet $timestamp = substr($value['timestamp'], 6, 10);
//werkt niet $timestamp = date('d-m-Y H:i:s', $timestamp);
//Table
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('B2', 'Beller ')
->setCellValue('D2', 'Beller nummer')
->setCellValue('F2', 'Datum')
->setCellValue('H2', 'ontvanger naam')
->setCellValue('J2', 'ontvanger nummer')
->setCellValue('L2', 'Billing seconds')
->setCellValue('N2', 'Direction')
// array
->setCellValue('B3', 'hi')
->setCellValue('D3', 'hi')
->setCellValue('F3', 'hi')
->setCellValue('H3', 'hi')
->setCellValue('J3', 'ontvanger nummer')
->setCellValue('L3', 'Billing seconds')
->setCellValue('N3', 'Direction');
//Werkt niet }