how to export data to an excel by preserving styles
Hi All,
I am trying to export data to an excel using ColdFusion. Below is my code.
<cfheader name="content-disposition" value="attachment; filename=dashboard.xls"> <cfcontent type="application/msexcel">
<table width="200" border="1"> <tr> <td width="40"> </td> <td width="160"> <table width="160" border="1"> <tr> <td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td><td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td> <td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td><td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td> </tr> </table> </td> </tr> <tr> <td width="40"> </td> <td width="160"> <table width="160" border="1"> <tr> <td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td><td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td> <td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td><td width="20" bgcolor="red"> </td><td width="20" bgcolor="black"> </td> </tr> </table> </td> </tr> </table> |
When I try to execute above code by commenting <cfheader><cfcontent> then the output is perfect. styles are preserved. And when I uncomment <cfheader><cfcontent> and execute code, then an excel file will get open. But all the styles are lost. So how to preserve all styles(table width etc.) in excel.
Can anybody please assist me on this. Thanks in advance.
Regards,
Manoz.
