[RESOLVED] [2005] Hi, how to create automatically pdf report based on crystal report data
hi, based on the data displayed in the crystal report...
i wanted to automatically make it as pdf report..
codes below is work perfectly.. how could i create a .pdf report when i click create pdf button and save it to c: drive how to do..?
here is my codes:
Code:
Private Sub ConnectionPrint()
If cnReport.State = ConnectionState.Closed Then
cnReport = New OleDbConnection
cnReport.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Data\RSODB.mdb;User Id=admin;Password=;"
cnReport.Open()
End If
End Sub
Private Sub GetRecords() '(ByVal myRSONOfilter As String)
myRSONOfilterReport = Me.TextBox1.Text
dsReport.Clear()
dsReport = New DataSet
daReport = New OleDbDataAdapter("Select * from FinalReportV2 where RSONO=" & myRSONOfilterReport & "", cnReport)
daReport.Fill(dsReport, "FinalReportV2")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Priview.Click
ConnectionPrint()
GetRecords()
' Fill the DataSet.
daReport.Fill(dsReport)
' Make a report and bind the DataSet to it.
Dim rpt As New CrystalFinalOff
rpt.SetDataSource(dsReport)
' Bind the viewer to the report.
CrystalReportViewer1.ReportSource = rpt
'CrystalReportViewer1.PrintReport()
End Sub
Please help...
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
There is an Export class which you call call to export the report to a pdf depending upon the required arguments.
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
yes i tried it but what i wanted to have is automatically generate the pdf report and save it to the c drive because the reason why i ave to save it c drive beacause i want to automaitcally send it by email as an attachment...
someone help me here please..
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
There should be an ExportToDisk method which you can set up with the path to export the pdf to. Post you code you have so far.
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
I can't continue here..
as of now under button1 i have this code..
Code:
ConnectionPrint()
GetRecords()
' Fill the DataSet.
daReport.Fill(dsReport)
' Make a report and bind the DataSet to it.
Dim rpt As New CrystalFinal
rpt.SetDataSource(dsReport)
' Bind the viewer to the report.
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.ExportReport()
'CrystalReportViewer1.PrintReport()
Dim CrystalOptions As [Shared].ExportOptions
'i have error on this line of code below..
CrystalOptions = rpt.ExportOptions
CrystalOptions.ExportDestinationType = "C;\"
CrystalOptions.ExportFormatOptions
CrystalOptions.FormatTyp = crEFTWordForWindows
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
Someone help me please..?
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
Hi, someone help please how could i export data in my crystal report to pdf file and save it to c drive..
please help..
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
Please convert this code in VB.
Code:
//Imports
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
Code:
string exportFilePath = Server.MapPath("myfile.pdf");
ReportDocument oRpt = new ReportDocument();
oRpt.Load(Server.MapPath("Reports/MyReport.rpt"));
DiskFileDestinationOptions oDest = new DiskFileDestinationOptions();
oDest.DiskFileName = exportFilePath;
ExportOptions oExport = oRpt.ExportOptions;
oExport.ExportDestinationOptions = oDest;
oExport.ExportDestinationType = ExportDestinationType.DiskFile;
oExport.ExportFormatType = ExportFormatType.PortableDocFormat;
ParameterFields pFields = new ParameterFields();
ParameterField pField = new ParameterField();
ParameterDiscreteValue disVal = new ParameterDiscreteValue();
ParameterRangeValue rVal = new ParameterRangeValue();
// If you have parameter
pField.ParameterFieldName = "@ID";
// Value of the parameter
disVal.Value = "100";
pField.CurrentValues.Add(disVal);
pFields.Add(pField);
string serverName = "SERVER_NAME";
string databaseName = "DATABASE_NAME";
string userName = "USER_NAME";
string password = "PASSWORD";
oRpt.SetDatabaseLogon(userName,password,databaseName,databaseName,true);
oRpt.SetParameterValue("@ID","100");
oRpt.Export();
Thanks.
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
Thanks USAMAALAM, but i don't know how to convert on it to c# manually
i tried to use online converter but there is error on line 6 EOF error...
can u try to convert on it into vb .net for me..? thanks..
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
Thank for all reply..
i got it the way i wanted to be with the snippets help....
here is my code below..
Code:
Private Sub GetRecords() '(ByVal myRSONOfilter As String)
myRSONOfilterReport = Me.TextBox1.Text
dsReport.Clear()
dsReport = New DataSet
daReport = New OleDbDataAdapter("Select * from FinalReportV2 where RSONO=" & myRSONOfilterReport & "", cnReport)
daReport.Fill(dsReport, "FinalReportV2")
End Sub
Private Sub ConnectionPrint()
If cnReport.State = ConnectionState.Closed Then
cnReport = New OleDbConnection
cnReport.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\rso\Rsodb.mdb;User Id=admin;Password=;"
cnReport.Open()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Priview.Click
ConnectionPrint()
GetRecords()
' Fill the DataSet.
daReport.Fill(dsReport)
' Make a report and bind the DataSet to it.
Dim rpt As New CrystalFinal
rpt.SetDataSource(dsReport)
' Bind the viewer to the report.
CrystalReportViewer1.ReportSource = rpt
'CrystalReportViewer1.ExportReport()
'CrystalReportViewer1.PrintReport()
Dim report As New CrystalFinal()
Dim exportOptions As New ExportOptions()
Dim pdfExportFormatOptions As New PdfRtfWordFormatOptions()
Dim diskDestinationOptions As New DiskFileDestinationOptions()
' Set the export format and format options
exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
pdfExportFormatOptions.FirstPageNumber = 1
pdfExportFormatOptions.LastPageNumber = 5
pdfExportFormatOptions.UsePageRange = True
exportOptions.ExportFormatOptions = pdfExportFormatOptions
' Set the disk file options.
exportOptions.ExportDestinationType = ExportDestinationType.DiskFile
diskDestinationOptions.DiskFileName = "C:\RSO " & Me.TextBox1.Text & ".pdf"
exportOptions.DestinationOptions = diskDestinationOptions
' report.Load("rpt.rpt")
report.Export(exportOptions)
report.Close()
End Sub