Export to Excel using PHP - cell text always black

Hi

How do I export to excel but retain the correct font colour? In the grid text can appear in many different colours but as soon as I export into Excel it reverts to black. I’ve tried mygrid.toExcel(‘generate.php’,‘full_color’) and mygrid.toExcel(‘generate.php’,‘color’) but neither seem to make any difference.

Thanks

Steve

Are you setting text color for whole cell or for different sub-tags inside of the cell ?
Grid can export first type of coloring ( “full_color” mode ) but will not be able to export second type of coloring.

This is the XML (part)

<?xml version="1.0" encoding="UTF-8"?> Monday 24th Sep 2012 Text here 7:30 - 17:03 9 hrs 33 mins ....

Hi,
could you provide complete demo? It works correctly at local machine.

Here it is. I have tried using Excel 2010 and LibreOffice Calc (don’t have access to Excel 2007).

.even{ background-color:#E6E6FA; } .uneven{ background-color:#F0F8FF; }
Printable view

and the xml:-

<?xml version="1.0" encoding="UTF-8"?> Monday 24th Sep 2012 A name 7:30 - 17:03 9 hrs 33 mins B Name 7:43 - 17:02 9 hrs 19 mins C Name 7:43 - 17:02 9 hrs 19 mins D Name 7:43 - 8:45 1 hrs 1 mins

Thanks for your help.

Regards

Steve

Hi,
please, try to update grid-pdf-php and grid-excel-php from here:
viewtopic.php?f=23&t=20151

Make sure, that you use the last dhtmlxgrid_export.js
Also make sure, please, that you use full_color mode in toPDF and toExcel calls.

Provided sample works correctly with the last version of export.

Also please remove the follow line:

mygrid.setInitWidths("*,*,*,*");

That worked thanks.

Now I just need to sort out the following error when going to PDF:

gridPdfWrapper.php at 326 : Division by zero :slight_smile:

Hi,
this problem appears because * sign is used for initial columns width.