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

[Solved] Rad Grid Export to Excel formatting

1 Answer 259 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kavi
Top achievements
Rank 1
Kavi asked on 09 Nov 2009, 10:01 AM
Hello,

I've included an Export to excel feature for my grid, i'm facing few issues

1. I'm unable to add borders for the excel sheet. is it that i can add border for only one edge of the row/column?

BorderStyles border = new BorderStyles();  
                border.Color = Color.Black;  
                border.Weight = 1;  
                border.LineStyle = LineStyle.Continuous;  
                border.PositionType = PositionType.Top;  
                border.PositionType = PositionType.Right;  
                border.PositionType = PositionType.Left;  
                border.PositionType = PositionType.Bottom;  
                style.Borders.Add(border); 
 I've added the above code inside "RadGrd1_ExcelMLExportStylesCreated", but the excel generated has boder only for the last position type (i.e. border.PositionType = PositionType.Bottom;) the rest are overwritten.


2. I'm trying to dynamically generate the name of the excel, on clik of the export to excel button a file download window is displayed with the name which i've specified and click of "Save" this works fine. But on click of "Open" the excel files has different name (junk values). Also how do we change the sheet names.
string date = System.DateTime.Today.Date.ToString();  
string filename = "Grid Details_" + date;              
RadGrd1.ExportSettings.FileName = filename;  
RadGrd1.MasterTableView.ExportToExcel(); 
 


3. The Excel which is generated does not get aligned (i.e. Some texts are getting hidden by the next column), how do i wrap and unwrap the column text through code.

Thanks in advance.
Kavi

 

 

1 Answer, 1 is accepted

Sort by
0
Johny
Top achievements
Rank 1
answered on 13 Nov 2009, 08:28 AM
Hi Kavi,

1. Try to create a new BorderStyles object for every border you want to add:

BorderStyles border = new BorderStyles(); 
        border.Color = Color.Black; 
        border.Weight = 1; 
        border.LineStyle = LineStyle.Continuous; 
        border.PositionType = PositionType.Top; 
        style.Borders.Add(border); 
 
border = new BorderStyles(); 
        border.Color = Color.Black; 
        border.Weight = 1; 
        border.LineStyle = LineStyle.Continuous; 
        border.PositionType = PositionType.Bottom; 
        style.Borders.Add(border); 
... 

2. Please try setting:

RadGrd1.ExportSettings.OpenInNewWindow = true

3. I am not able to get this one. I guess it depends on the column types and settings used. If you post a code snippet of your grid markup I might be able to help.

Thanks
Johny


Tags
Grid
Asked by
Kavi
Top achievements
Rank 1
Answers by
Johny
Top achievements
Rank 1
Share this question
or