Hi All,
I have create a report which is exported to pdf with a typed dataset as datasource.
The code bellow is running well but it always generate a new .rpt file on the server.
I wonder how to delete that .rpt file in the temp dir.
Does anyone have an idea?
Thanks,
Here is my VB code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
reportDocument1 = New CrystalReport3()
Dim ds As New dsAdhesionClub()
Dim dr As dsAdhesionClub.ClubRow = ds.Club.NewClubRow
dr.clubName = "Club Name"
dr.firstName = "First Name"
dr.lastName = "Last Name"
dr._function = "Web Dev"
dr.eMail = "Email"
dr.gender = "Male"
ds.Club.Rows.Add(dr)
ShowReport(reportDocument1, ds)
End Sub
Public Sub ShowReport(ByVal r As ReportClass, ByVal ds As DataSet)
r.SetDataSource(ds)
Dim objRep As TextObject = r.ReportDefinition.ReportObjects.Item("Text7"
objRep.Text = "Club Name"
objRep.ObjectFormat.CssClass = ""
'Sets the file name for the PDF
Dim diskDestin As New DiskFileDestinationOptions()
Dim path As String = "C:\myPdf" & Session.SessionID.ToString & ".pdf"
diskDestin.DiskFileName = path
'Sets export options, including format of file to PDF
Dim expOption As ExportOptions = r.ExportOptions
With expOption
.DestinationOptions = diskDestin
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
With r
.FormatEngine.PrintOptions.PaperSize = PaperSize.PaperA4
.FormatEngine.PrintOptions.PaperOrientation = PaperOrientation.Portrait
.Export()
.Close()
End With
r = Nothing
End Sub
I have create a report which is exported to pdf with a typed dataset as datasource.
The code bellow is running well but it always generate a new .rpt file on the server.
I wonder how to delete that .rpt file in the temp dir.
Does anyone have an idea?
Thanks,
Here is my VB code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
reportDocument1 = New CrystalReport3()
Dim ds As New dsAdhesionClub()
Dim dr As dsAdhesionClub.ClubRow = ds.Club.NewClubRow
dr.clubName = "Club Name"
dr.firstName = "First Name"
dr.lastName = "Last Name"
dr._function = "Web Dev"
dr.eMail = "Email"
dr.gender = "Male"
ds.Club.Rows.Add(dr)
ShowReport(reportDocument1, ds)
End Sub
Public Sub ShowReport(ByVal r As ReportClass, ByVal ds As DataSet)
r.SetDataSource(ds)
Dim objRep As TextObject = r.ReportDefinition.ReportObjects.Item("Text7"
objRep.Text = "Club Name"
objRep.ObjectFormat.CssClass = ""
'Sets the file name for the PDF
Dim diskDestin As New DiskFileDestinationOptions()
Dim path As String = "C:\myPdf" & Session.SessionID.ToString & ".pdf"
diskDestin.DiskFileName = path
'Sets export options, including format of file to PDF
Dim expOption As ExportOptions = r.ExportOptions
With expOption
.DestinationOptions = diskDestin
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
With r
.FormatEngine.PrintOptions.PaperSize = PaperSize.PaperA4
.FormatEngine.PrintOptions.PaperOrientation = PaperOrientation.Portrait
.Export()
.Close()
End With
r = Nothing
End Sub