I want to download excel with multipe sheet,I passing two datatable for two sheets table for sheet1 and table1 for sheet2, while i submit excel downloading no issuse while opening excel file iam getting dialog box with error
Public Sub ExportToSpreadsheet(ByVal table As DataTable, ByVal table1 As DataTable, ByVal name As String)
Try
Dim attachment As String = "attachment; filename=" & name & Format(CDate(Now), "_ddMMyyyy_hhmmss") & ".xls"
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.AddHeader("content-disposition", attachment)
Response.Buffer = True
Response.Charset = ""
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.Write(vbLf)
Dim ef As ExcelFile
ef = New ExcelFile()
Dim ws As ExcelWorksheet
ws = ef.Worksheets.Add("Summary")
Dim ws1 As ExcelWorksheet
ws1 = ef.Worksheets.Add("MissingData")
ws.InsertDataTable(table, "A1", True)
ws1.InsertDataTable(table1, "A1", True)
Dim MyMemoryStream As New MemoryStream()
ef.SaveXls(MyMemoryStream)
MyMemoryStream.WriteTo(Response.OutputStream)
Catch excp As Exception
Errors.WriteToErrorLogWithUserName(excp, "", Session("UserName").ToString())
End Try
End Sub
Please do need full to us