Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to PDF

Status
Not open for further replies.

swetham

Programmer
May 5, 2010
257
0
0
DE
Before i have posted it in a wrong forum, now i am posting it here, I have designed a report which in which i have wriiten the Sql Join query in "Command". I get the data from the Query wriiten in "Command" , I have three parameterfields in the report ProjecT_name,start_date,end_date. I have filtered the query data in select expert->record. In report if i preview the data everything is working fine. But from vb.net i need to export the report to pdf. I wrote the following code,

Function Export_report()


report_path ="D:\abc.rpt"

cryrpt.Load(report_path)

Dim prj_name As String

Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table

With crConnectionInfo
.ServerName = "TaskSheet.dsn"
.Password = "123"
End With

CrTables = cryrpt.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next

prj_name = cb_Project.Text

Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues

crParameterFieldDefinitions = cryrpt.DataDefinition.ParameterFields

crParameterFieldLocation = crParameterFieldDefinitions.Item("Project_name")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = prj_name
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

crParameterFieldLocation = crParameterFieldDefinitions.Item("start_date")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = start_date
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

crParameterFieldLocation = crParameterFieldDefinitions.Item("End_date")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = end_date
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

Dim filename As String
Try

With SFD
.DefaultExt = ".pdf"

.Filter = "Pdf Files (*.pdf)|*.pdf"

.InitialDirectory = "C:\My Documents"
End With

SFD.CreatePrompt = False

If SFD.ShowDialog() = DialogResult.OK Then
If SFD.FileName "" Then
filename = SFD.FileName
Else
msg.ShowMSG("File name should not be empty", Project_name, "Ok")
End If
Else
Application.Exit()
End If

Catch ex As Exception
msg.ShowMSG("The File is in use by another application", Project_name, "Ok")
End Try

Try
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()

CrDiskFileDestinationOptions.DiskFileName = filename
CrExportOptions = cryrpt.ExportOptions

Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions

End With

cryrpt.Export()
cryrpt.Close()

Catch ex As Exception
MsgBox(ex.ToString & " -- export button last block")
End Try
End Function

Reprot is getting exported but with no data.

CAn anyone please help me out?

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top