Excel
Dim tw As New StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim frm As HtmlForm = New HtmlForm()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=Report_Listing.xls")
Response.Charset = ""
EnableViewState = False
Controls.Add(frm)
frm.Controls.Add(gvSearch)
frm.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
Word
Dim tw As New StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim frm As HtmlForm = New HtmlForm()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=Report_Listing.xls")
Response.Charset = ""
EnableViewState = False
Controls.Add(frm)
frm.Controls.Add(gvSearch)
frm.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
Word
Private Sub ExportToPdf(ByVal rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal fileName As String)
If fileName Is Nothing Then fileName = "DelinquencyReport"
Dim cr As CrystalDecisions.CrystalReports.Engine.ReportDocument = rpt
Dim reportName As String = "/" & fileName & ".pdf"
Dim strFile As String = Server.MapPath(Global.REPORT_LOCATION) & reportName
cr.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
cr.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
Dim dskOptions As New CrystalDecisions.Shared.DiskFileDestinationOptions
dskOptions.DiskFileName = strFile
cr.ExportOptions.DestinationOptions = dskOptions
Try
cr.Export()
Page.RegisterStartupScript("ExportToPdf", "<script language=Javascript>window.open('" & Global.REPORT_LOCATION_REDIRECTION & reportName & "','_blank');</script>")
Catch ex As Exception
Throw ex
Finally
dskOptions = Nothing
cr = Nothing
End Try
End Sub
----------
Try
repDoc = VendorInvoice.GetVendorInvoiceInformation(InvoiceType, IsPosted, Query)
ExportToPdf(repDoc, "VendorInvoiceReport")
'Session(Global.REPORT_DOCUMENT_SESSION_OBJECT) = repDoc
'Global.GotoControl(Page, Global.REPORT_VIEWER)
Catch ex As Exception
DisplayMessage(ex.Message)
Finally
repDoc = Nothing
VendorInvoice = Nothing
End Try
No comments:
Post a Comment