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

Format excel export

2 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 14 Jan 2013, 02:57 PM
Hi,

Trying to format the information when exported to excel.  Treid following examples online but nothing is working.  What it does now is export but nothing is alligned.  Need all columns centered on export and the gridlines created.  What command do I do this on and what Css works becuase what i am doing is not.

Protected Sub myIssueGrid_ExportCellFormatting(sender As Object, e As ExportCellFormattingEventArgs) Handles myIssueGrid.ExportCellFormatting
       Dim item As GridDataItem = DirectCast(e.Cell.Parent, GridDataItem)
       If item.ItemType = GridItemType.AlternatingItem Then
           item.Style("horizontal-align") = "middle"
       Else
           item.Style("horizontal-align") = "middle"
       End If
   End Sub
 
 
 If e.CommandName = "ExportToExcel" Then
           IsExport = True
           myIssueGrid.Columns(0).Visible = False
       End If
 
 
<CommandItemTemplate>
                                                   <table width="100%">
                                                       <tr>
                                                           <td style="width:50%"><asp:LinkButton ID="lnkTransfer" runat="server" CommandName="Trans" Text="Click to Transfer Items" Font-Underline="true"></asp:LinkButton></td>
                                                           <td  style="width:50%" align="right"><asp:Button ID="btnExport" runat="server" CommandName="ExportToExcel" Text="Export Excel" /></td>
                                                       </tr>
                                                   </table>
                                               </CommandItemTemplate>

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Jan 2013, 06:24 AM
Hi Kevin,

Try the following code snippet.

VB:
Protected Sub RadGrid1_ExportCellFormatting(sender As Object, e As ExportCellFormattingEventArgs)
    Dim item As GridDataItem = DirectCast(e.Cell.Parent, GridDataItem)
    If item.ItemType = GridItemType.Item Then
        item.Style("text-align") = "center"
    Else
        item.Style("text-align") = "center"
    End If
End Sub

Hope this helps.

Regards,
Princy.
0
Kevin
Top achievements
Rank 1
answered on 16 Jan 2013, 03:02 PM
Thanks
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Share this question
or