G
Guest
I have an app with 2 datagrids that are displayed in a page_load event.
I use the following code to render it to an Excel workbook.
sFile = sFile.Replace("/", "-")
ClearControls(DataGrid1)
Select Case RbtnExport.SelectedItem.Value
Case "Excel"
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("content-disposition", "attachment; filename=" & sFile
& ".xls")
Case "Word"
Response.ContentType = "application/vnd.ms-word"
Response.AppendHeader("content-disposition", "attachment; filename=" & sFile
& ".doc")
End Select
' Remove the charset from the Content-Type header.
Response.Charset = ""
' Turn off the view state.
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
DataGrid1.RenderControl(hw)
' Write the HTML back to the browser.
Response.Write(tw.ToString())
I know that I could create another excel spreadsheet and do the 2nd
datagrid, but would like to put the 2nd datagrid in a workbook inside the
same spreadsheet as the first one.
Is there a way to do this?
Thanks
SC
I use the following code to render it to an Excel workbook.
sFile = sFile.Replace("/", "-")
ClearControls(DataGrid1)
Select Case RbtnExport.SelectedItem.Value
Case "Excel"
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("content-disposition", "attachment; filename=" & sFile
& ".xls")
Case "Word"
Response.ContentType = "application/vnd.ms-word"
Response.AppendHeader("content-disposition", "attachment; filename=" & sFile
& ".doc")
End Select
' Remove the charset from the Content-Type header.
Response.Charset = ""
' Turn off the view state.
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
DataGrid1.RenderControl(hw)
' Write the HTML back to the browser.
Response.Write(tw.ToString())
I know that I could create another excel spreadsheet and do the 2nd
datagrid, but would like to put the 2nd datagrid in a workbook inside the
same spreadsheet as the first one.
Is there a way to do this?
Thanks
SC