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

Why Export is not working with thi code

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
grand lorie
Top achievements
Rank 1
grand lorie asked on 27 Mar 2010, 01:00 PM
Hi
I have a Grid with export options using the following code as a code behinde did not do anything when click the button... any Idea?
here is the code;
---------------------------------------------------------------

Partial Class Archive_Folder_OrdersList
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        Select Case DropDownList1.SelectedValue
            Case "Export to CSV"
                SetExportSettings()
                RadGrid1.MasterTableView.ExportToCSV()
                Exit Select
            Case "Export to PDF"
                SetExportSettings()
                RadGrid1.MasterTableView.ExportToPdf()
                Exit Select
            Case "Export to Excel"
                SetExportSettings()
                RadGrid1.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.Html
                RadGrid1.MasterTableView.ExportToExcel()
                Exit Select
            Case "Export to Styled Excel"
                RadGrid1.ExportSettings.IgnorePaging = ckbxAllPages.Checked
                RadGrid1.ExportSettings.ExportOnlyData = True
                RadGrid1.ExportSettings.OpenInNewWindow = ckbxNewWindow.Checked
                RadGrid1.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML
                RadGrid1.MasterTableView.ExportToExcel()
                Exit Select
            Case "Export to Word"
                SetExportSettings()
                RadGrid1.MasterTableView.ExportToWord()
                Exit Select

        End Select
    End Sub
    Private Sub SetExportSettings()
        RadGrid1.ExportSettings.IgnorePaging = ckbxAllPages.Checked
        RadGrid1.ExportSettings.ExportOnlyData = ckbxDataOnly.Checked
        RadGrid1.ExportSettings.OpenInNewWindow = ckbxNewWindow.Checked
    End Sub
    Protected Sub RadGrid1_ExcelMLExportRowCreated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs)
        If e.RowType = Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.DataRow Then
            If e.Row.Cells(0) IsNot Nothing AndAlso DirectCast(e.Row.Cells(3).Data.DataItem, String).Contains("Suppliers") Then
                e.Row.Cells(0).StyleValue = "MyCustomStyle"
            End If
        End If
    End Sub
    Protected Sub RadGrid1_ExcelMLExportStylesCreated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs)
        For Each style As Telerik.Web.UI.GridExcelBuilder.StyleElement In e.Styles
            If style.Id = "headerStyle" Then
                style.FontStyle.Bold = True
                style.FontStyle.Color = System.Drawing.Color.Gainsboro
                style.InteriorStyle.Color = System.Drawing.Color.Wheat
                style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid
            ElseIf style.Id = "itemStyle" Then
                style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke
                style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid
            ElseIf style.Id = "alternatingItemStyle" Then
                style.InteriorStyle.Color = System.Drawing.Color.LightGray
                style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid
            End If
        Next

        Dim myStyle As New Telerik.Web.UI.GridExcelBuilder.StyleElement("MyCustomStyle")
        myStyle.FontStyle.Bold = True
        myStyle.FontStyle.Italic = True
        myStyle.InteriorStyle.Color = System.Drawing.Color.Gray
        myStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid
        e.Styles.Add(myStyle)

    End Sub
End Class
------------------------------------------------------

Thanks for any help

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Mar 2010, 04:44 PM
Hello Grand,

Please examine the following links:
Radgrid export to excel not working
ExportToPDF not working
Ajaxify RadGrid not working

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.
Tags
Grid
Asked by
grand lorie
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or