Of course! Thank you for asking. Here it is, from where I call my stored proc.
(Please ignore the response.write()'s that don't belong thereCode:Dim adapter As New SqlDataAdapter(command) Try adapter.Fill(ds) Catch ex As Exception Response.Write("Submit() Exception " + ex.Message) conn.Close() conn.Dispose() conn = Nothing Exit Sub End Try Me.gvAgentCommissions.DataSource = ds Me.gvAgentCommissions.DataBind() 'Try ' ' Set the content type to Excel. ' Response.ContentType = "application/vnd.ms-excel" ' ' 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. ' Me.gvAgentCommissions.RenderControl(hw) ' ' Write the HTML back to the browser. ' Response.Write(tw.ToString()) ' ' End the response. ' Response.End() 'Catch ex As Exception ' ' Response.Write("Going to Excel() Exception " + ex.Message) ' Dim s As String ' s = ex.Message 'End Try Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" ' Response.AddHeader("Content-Disposition", "inline;filename=Filename.xls") Response.AddHeader("Content-Disposition", "attachment; filename=ExcelFile.xls") Response.Charset = "" Me.EnableViewState = False Dim strStyle As String = "<style>.text { mso-number-format:\@; } </style>" Dim oStringWriter As New System.IO.StringWriter Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter) oHtmlTextWriter.WriteLine(strStyle) Me.gvAgentCommissions.RenderControl(oHtmlTextWriter) Response.Write(oStringWriter.ToString()) Response.End())




)
Reply With Quote