PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.19k forks source link

PHPExcel changes Templatestyles #796

Open Norcoen opened 8 years ago

Norcoen commented 8 years ago

I read a template.xslx with some headers and styling in the first 2 rows and fill it from an array, starting at A3. PHPExcel changes the style of the header, in my case from lightblue background to a light-blueish-grey. On merged cells he drops the white text color back to black. tpl_ecoparts.xlsx

KoulSlou commented 8 years ago

I think I have faced with the same issue. In code I read template file that have background colors for the first 3 rows. This is how original template looks like:

original_template

Here is a sample code - I just open 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);

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
    $objWriter->save('checkColor.xlsx');
    die('finish');`

And now if you look into created file - checkColor.xlxs - you will see that colors are totally different.

after open

My question is why colors are changing? Is there any way to prevent it? So far all I can do is specify correct colors before calling "createWriter"

dsepulveda commented 7 years ago

@KoulSlou did you find a solution for this? this is driving me crazy!