I have an Excel template that I need to fill out in php script. Table's headers are highlighted with different colours:
In php script I open template, add some data and save file:
//Template from VitalSource
$template = APPLICATION_PATH.'/../public/VitalSourceTemplate.xlsx';
// Read the file
$fileType = PHPExcel_IOFactory::identify($template);
$objReader = PHPExcel_IOFactory::createReader($fileType);
$objPHPExcel = $objReader->load($template);
$objPHPExcel->setActiveSheetIndex(0);
$row = 4;
/*
Add new rows to the Excel file
*/
// Write the file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
$objWriter->save('testVS.xlsx');
Data is here, the only problem is that header colours are changing:
What can be the problem? How to leave original style of cells?
UPD
Here is a dropbox link to the template file - dropbox
UPD 2
When I convert template file from xlsx to xls everything works as expected.
Here is a link to the xlsx template - link
Here is a link to the xls template - link
Does PHPExcel process xlsx and xls colors differently? At other hand I use Numbers on Mac to open Excel files and converting them to xlsx and xls - probably there is some bug with Numbers. Appreciate any help and information.