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

RadGrid Export data to Excel

2 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ban
Top achievements
Rank 1
Ban asked on 24 Jan 2009, 05:24 PM
Hi,
I am using ExportToExcel in RadGrid, inside "ExcelMLExportStylesCreated" , "ExcelMLExportRowCreated" events I change my data format (Font Style, InteriorStyle, ......) but the only thing I could not do is How I can set borders to my cells !!? .. Will you please help me to figure out how.

Thanks
Ban

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 Jan 2009, 02:23 PM
Hello Ban,

Sample approach is shown below:
protected void RadGrid1_ExcelMLExportStylesCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e) 
    BorderStylesCollection borders = new BorderStylesCollection(); 
    BorderStyles borderStyle = null
    for (int i = 1; i <= 4; i++) 
    { 
        borderStyle = new BorderStyles(); 
        borderStyle.PositionType = (PositionType)i; 
        borderStyle.Color = System.Drawing.Color.Black; 
        borderStyle.LineStyle = LineStyle.Continuous; 
        borderStyle.Weight = 1.0; 
        borders.Add(borderStyle); 
    } 
 
    foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles) 
        foreach (BorderStyles border in borders) 
            style.Borders.Add(border); 

I hope this helps.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mark Galbreath
Top achievements
Rank 2
answered on 20 Nov 2009, 03:11 PM
You the man for Ban, Dan!  (sorry, couldn't help myself...)
Tags
Grid
Asked by
Ban
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Mark Galbreath
Top achievements
Rank 2
Share this question
or