This is a migrated thread and some comments may be shown as answers.

Preserving cell style when exporting to Excel

5 Answers 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel Brom
Top achievements
Rank 1
Joel Brom asked on 30 Apr 2010, 06:37 PM
I have a RadGrid that I am establishing cell styles in the itemdatabound method.  I export this grid to Excel .
     <ExportSettings HideStructureColumns="true" ExportOnlyData="false" IgnorePaging="true" Excel-Format="ExcelML" OpenInNewWindow="true" > 
     </ExportSettings> 
How do I preserve the cell styles (color, text color, bolding, etc ) that I set in the grid .

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 05 May 2010, 11:52 AM
Hi Joel,

Due to the fact that this format is based on standard HTML/CSS it is quite straightforward to control the appearance of the output using inline styles. You can apply CSS tags/classes to the cells/rows/tables, etc.
Please review the followinh help topic for more information of RadGrid export styling.



Kind regards,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joel Brom
Top achievements
Rank 1
answered on 05 May 2010, 06:19 PM

I must be doing something wrong because the  OnExcelExportCellFormatting method is not being executed.  The export is accomplished via the following code

    protected void ExportToExcel(object sender, System.EventArgs e)  
    {  
        RptCrdGrdGrid.ExportSettings.ExportOnlyData = false;  
        RptCrdGrdGrid.ExportSettings.IgnorePaging = true;  
        RptCrdGrdGrid.ExportSettings.OpenInNewWindow = true;  
 
        RptCrdGrdGrid.MasterTableView.ExportToExcel();  
    }  
 
 

 

 

 

0
Maria Ilieva
Telerik team
answered on 11 May 2010, 08:34 AM
Hi Joel,

Please accept apologize for the previous post. I did not notice that in the Export settings tag you have Excel-Format="ExcelML”. If this is the correct format you need to export to, please refer to the following help topic.

I hope this helps. Let us know if further assistance is needed



Sincerely yours,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joel Brom
Top achievements
Rank 1
answered on 11 May 2010, 09:25 PM
Things I needed to do to implement this
1. Add using statement for Telerik.Web.UI.GridExcelBuilder
2. Add OnExcelMLExportRowCreated to the RadGrid definition
3. Add OnExcelMLExportStylesCreated to the RadGrid definition

I see that I can now format cells by name.  It appears that setting the myStyle.InteriorStyle.Color = System.Drawing.Color.Blue
has no effect.

I need to generate different styles within the cells based on the value (text) of the cell.  I do not see a Get Method for the text or value.
Is this possible?
0
Maria Ilieva
Telerik team
answered on 13 May 2010, 10:05 AM
Hello Joel,

In order to set properly the cell format you should also add pattern setting. For example:

style.InteriorStyle.Pattern = InteriorPatternType.Solid;

Please find attached a sample application which demonstrates the required functionality.
Test it on your side and let me know if it helps.



Regards,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Joel Brom
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Joel Brom
Top achievements
Rank 1
Share this question
or