|
-
Jul 30th, 2008, 01:48 AM
#1
Thread Starter
Fanatic Member
[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...
Last edited by edgarbenilde; Jul 30th, 2008 at 01:51 AM.
-
Jul 30th, 2008, 01:56 AM
#2
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 30th, 2008, 02:48 AM
#3
Thread Starter
Fanatic Member
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..
-
Jul 30th, 2008, 02:52 AM
#4
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 30th, 2008, 03:53 AM
#5
Thread Starter
Fanatic Member
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
-
Jul 30th, 2008, 04:51 AM
#6
Thread Starter
Fanatic Member
Re: [2005] Hi, how to create automatically pdf report based on crystal report data
Someone help me please..?
-
Jul 30th, 2008, 06:07 AM
#7
Thread Starter
Fanatic Member
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..
-
Jul 30th, 2008, 08:10 AM
#8
Frenzied Member
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.
-
Jul 30th, 2008, 07:04 PM
#9
Thread Starter
Fanatic Member
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..
-
Jul 30th, 2008, 08:05 PM
#10
Thread Starter
Fanatic Member
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
Last edited by edgarbenilde; Sep 4th, 2008 at 06:18 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|