Exporting ASP.NET datagrid to Excel not showing color of datacell contents
I am exporting an ASP.NET datagrid to excel and having an issue with the colors exporting with it. I know in order for the cells color to be exported to excel you must set the background color of the cell. I have several lines of text in the cell, parts of the text are wrapped in a div and the div background color is set. This is the color I need exported. Is there a way to do this? I have included an example below of what would be found in a cell.
<div style="background-color: #b88eb5;>
Random Text 1
</div>
<div style="background-color: #8ccb83;>
Random Text 2
</div&开发者_开发知识库gt;
Based on the clarification in comments, I don't believe this can be directly accomplished using built-in DataGrid export functionality. Since the "background color" for any given cell is:
- Held by a child element of the cell.
- One of multiple colors from which to choose.
then transferring the correct background color to the output file is going to require custom export code.
精彩评论