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
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