S
Sze
I got a method to export the report to PDF directly, However, it sometimes
work (export the pdf in 5 secs) but sometimes. (there is dialog box prompt
out and said downloading.........) , and the doc can't export as pdf
Public Sub ExportToCrystalPDF(ByVal Filter As String, ByVal Filename As
String)
Dim Login As New MasterData.Login
Dim rptCount As New
CrystalDecisions.CrystalReports.Engine.ReportDocument()
rptCount.Load(Server.MapPath("./Reports/" + Filename + ".rpt"))
' Dim customerFilePath As String =
Server.MapPath("App_Data\FineArtMaster.xsd")
Login.Sub_CrystalLogin(rptCount)
Dim crParameterFieldDefinitions As
CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions =
rptCount.DataDefinition.ParameterFields
' rptCount.RecordSelectionFormula = "TRUE and
{mounting.mounting} = ""Mounting Type 1"""
rptCount.RecordSelectionFormula = Filter
Dim crExportOptions As ExportOptions
crExportOptions = rptCount.ExportOptions
With crExportOptions
.FormatOptions = New PdfRtfWordFormatOptions()
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
Dim req As ExportRequestContext = New ExportRequestContext()
req.ExportInfo = crExportOptions
Dim st As System.IO.Stream
st = rptCount.FormatEngine.ExportToStream(req)
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename= " &
Filename & ".pdf")
Dim b(st.Length) As Byte
st.Read(b, 0, st.Length)
Response.BinaryWrite(b)
Response.End()
Response.Close()
rptCount.Dispose()
st.Dispose()
End Sub
work (export the pdf in 5 secs) but sometimes. (there is dialog box prompt
out and said downloading.........) , and the doc can't export as pdf
Public Sub ExportToCrystalPDF(ByVal Filter As String, ByVal Filename As
String)
Dim Login As New MasterData.Login
Dim rptCount As New
CrystalDecisions.CrystalReports.Engine.ReportDocument()
rptCount.Load(Server.MapPath("./Reports/" + Filename + ".rpt"))
' Dim customerFilePath As String =
Server.MapPath("App_Data\FineArtMaster.xsd")
Login.Sub_CrystalLogin(rptCount)
Dim crParameterFieldDefinitions As
CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions =
rptCount.DataDefinition.ParameterFields
' rptCount.RecordSelectionFormula = "TRUE and
{mounting.mounting} = ""Mounting Type 1"""
rptCount.RecordSelectionFormula = Filter
Dim crExportOptions As ExportOptions
crExportOptions = rptCount.ExportOptions
With crExportOptions
.FormatOptions = New PdfRtfWordFormatOptions()
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
Dim req As ExportRequestContext = New ExportRequestContext()
req.ExportInfo = crExportOptions
Dim st As System.IO.Stream
st = rptCount.FormatEngine.ExportToStream(req)
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename= " &
Filename & ".pdf")
Dim b(st.Length) As Byte
st.Read(b, 0, st.Length)
Response.BinaryWrite(b)
Response.End()
Response.Close()
rptCount.Dispose()
st.Dispose()
End Sub