I currently able to export multiple grids to excel in one file. Problem is that me superiors would like it to be prettier.
Is there a way to export multi grids in html format? Please help!
My current export code is this:
Dim gridControlsFound As New List(Of RadGrid)()
gridControlsFound.Add(grdBCA_Assumptions_TravelDemand)
gridControlsFound.Add(grdBCA_Assumptions_StartupCosts)
gridControlsFound.Add(grdBCA_Assumptions_AnnualCosts)
ExportMultiGrid(gridControlsFound, "GrantReport")
Private Sub ExportMultiGrid( _
ByVal gridControlsFound As List(Of RadGrid), _
ByVal FileName As String)
Dim tableXLS As New xls.Table()
Dim ExportInSingleSpreadsheet As Boolean = True
For Each grid As RadGrid In gridControlsFound
grid.AllowPaging = False
grid.CurrentPageIndex = 0
'grid.Rebind()
GenerateTable(grid, tableXLS)
Next
If ExportInSingleSpreadsheet = True Then
[structure].Tables.Add(tableXLS)
End If
Dim renderer As New xls.XlsBiffRenderer([structure])
Dim renderedBytes As Byte() = renderer.Render()
Response.Clear()
Response.AppendHeader("Content-Disposition:", "attachment; filename=" & FileName & ".xls")
Response.ContentType = "application/vnd.ms-excel"
Response.BinaryWrite(renderedBytes)
Response.[End]()
End Sub
Private Sub GenerateTable(grid As RadGrid, ByRef singleTable As xls.Table)
Dim ExportInSingleSpreadsheet As Boolean = True
If ExportInSingleSpreadsheet = False Then
singleTable = New xls.Table(grid.ID)
row = 1
col = 1
Else
If Not isFirstItem Then
row += 1
Else
isFirstItem = False
End If
End If
For i As Integer = 0 To grid.Columns.Count - 1
If grid.Columns(i).HeaderText.Length = 1 Then
If grid.Columns(i).UniqueName = "Discount1" Then
singleTable.Cells(i + 1, row).Value = txbDiscountRate_1.Text & "% discount rate ($ mil.)"
ElseIf grid.Columns(i).UniqueName = "Discount2" Then
singleTable.Cells(i + 1, row).Value = txbDiscountRate_2.Text & "% discount rate ($ mil.)"
Else
singleTable.Cells(i + 1, row).Value = grid.Columns(i).HeaderText
End If
Else
singleTable.Cells(i + 1, row).Value = grid.Columns(i).HeaderText
End If
Next
row += 1
For Each item As GridDataItem In grid.MasterTableView.Items
For Each column As GridColumn In grid.Columns
singleTable.Cells(col, row).Value = item(column.UniqueName).Text
col += 1
Next
col = 1
row += 1
Next
If ExportInSingleSpreadsheet = False Then
[structure].Tables.Add(singleTable)
End If
End Sub