I am trying to export a programmatically created radgrid to excel. I am exporting Data only. I tried to export as HTML, but that caused Excel to freeze up. (Passing 1,000 records.) Part of the export requires that I change the styling on the items (background color), and the other part changes the dataformatstring to {0:C} for currency fields.
Is there a way to accomplish this? I tried a few suggestions I saw on here, but I'm stumped. Any help is appreciated. Thank you.
Is there a way to accomplish this? I tried a few suggestions I saw on here, but I'm stumped. Any help is appreciated. Thank you.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Dim radgrid2 As New RadGrid radgrid2.AutoGenerateColumns = True radgrid2.ID = "RadGrid2" Me.PlaceHolder1.Controls.Add(radgrid2) connSql.ConnectionString = sqlConn.ToString() Dim poSqlCom As New SqlCommand("dbo.getCurrQtrAll", connSql) poSqlCom.CommandType = CommandType.StoredProcedure poSqlCom.Parameters.AddWithValue("@UID", "SomeoneElse") Dim adapter As New SqlDataAdapter(poSqlCom) Dim links As New DataTable() Try adapter.Fill(links) Catch ex As Exception 'lblResult.Text = ex.Message If connSql.State = ConnectionState.Open Then connSql.Close() End If End Try radgrid2.DataSource = links radgrid2.Rebind() radgrid2.ExportSettings.Excel.FileExtension = "xls" radgrid2.ExportSettings.FileName = "Cur_Qtr_Rpt" radgrid2.ExportSettings.ExportOnlyData = True radgrid2.ExportSettings.IgnorePaging = True radgrid2.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML radgrid2.MasterTableView.ExportToExcel()End Sub