In the folllowing help article: you indicated that:
Although the HTML Excel format doesn't show any grid lines in the worksheet, you can mimic them by adding the following style to the generated output:
body { border:solid 0.1pt #CCCCCC; }
but you never indicated where this code should be placed?
I was assuming it would be applied to some property related to the export, but could not figure out how to use it.
I ended up doing the following instead:
which works, but the header row has a border on every cell in the entire workbook.
I only want borders on cells related to the output of the grid.
What is the best way to fix this?
                                Although the HTML Excel format doesn't show any grid lines in the worksheet, you can mimic them by adding the following style to the generated output:
body { border:solid 0.1pt #CCCCCC; }
but you never indicated where this code should be placed?
I was assuming it would be applied to some property related to the export, but could not figure out how to use it.
I ended up doing the following instead:
protected void RadGrid1_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e) {     GridDataItem item = e.Cell.Parent as GridDataItem;     e.Cell.Style["border"] = "solid 0.1pt #000000"; } protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) {     if (e.Item is GridHeaderItem && bIsExport)     {         GridHeaderItem item = e.Item as GridHeaderItem;         item.Style["border"] = "solid 0.1pt #000000";     } }  which works, but the header row has a border on every cell in the entire workbook.
I only want borders on cells related to the output of the grid.
What is the best way to fix this?
6 Answers, 1 is accepted
0
                                Hello Nano,
You should add this CSS rule to the exported page's head:
Best regards,
Daniel
the Telerik team
                                        You should add this CSS rule to the exported page's head:
protected void RadGrid1_GridExporting(object source, GridExportingArgs e){    if (e.ExportType == ExportType.Excel)    {        string css = "<style> body { border:solid 0.1pt #CCCCCC; }</style>";        e.ExportOutput = e.ExportOutput.Replace("</head>", css + "</head>");    }}Best regards,
Daniel
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
                                
                                                    Atlas
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 26 Jul 2010, 07:48 PM
                                            
                                        The solution you provided puts a border on every single row and column in the enitre workbook. I only want the border around the rows and columns of the returned data. If the data is being rendered in a table to Excel, then I want to apply the css there not the entire workbook?
                                        0
                                
                                                    Atlas
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 26 Jul 2010, 07:53 PM
                                            
                                        OK, 
With the help of your code, I figured it out:
                                        With the help of your code, I figured it out:
protected void RadGrid1_GridExporting(object source, GridExportingArgs e) {     if(e.ExportType == ExportType.Excel)     {         string css = "<style> td { border:solid 0.1pt #000000; }</style>";         e.ExportOutput = e.ExportOutput.Replace("</head>", css + "</head>");     } } 0
                                
                                                    Ed
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 31 Jan 2011, 03:43 PM
                                            
                                        Would anyone like to share this solution with us VB.Net developers that are having difficulity translating this C# code to VB.Net?
Please!
                                        Please!
0
                                
                                                    OPL
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 01 Feb 2011, 11:58 AM
                                            
                                        0
                                
                                                    Israel
                                                    
                                            
    Top achievements
    
            
                 Rank 1
                Rank 1
            
    
                                                
                                                answered on 06 Jan 2015, 02:10 PM
                                            
                                        THANKS!!!!