I have a dataset that I fill manually from a database using LINQ. I display the report using the normal functions as follows.
Public objRpt As New ReportDocument
Dim ds As New rptDataSet
Dim sc = From sch In db.StudentSchedules _
Join tms In db.TmsSchedules On tms.TmsDate Equals sch.SchDate _
Where sch.SchDate >= fromDate And sch.SchDate <= toDate _
Select sch, tms
Dim r As DataRow
Dim rs As DataRow
Dim cd As DataRow
For each dr In sc
Next
objRpt = New rptSchedule
objRpt.SetDataSource(ds)
MyCrystalReportViewer.ReportSource = objRpt
MyCrystalReportViewer.Refresh()
Up to this point everything works perfect. However if I use the menu command to convert it, it works in every format except pdf, where an error pops up and the pdf file doesn't get written.
The error is Error in File C:\temp_xxxx_.rpt
Operation not yet implemented.
Then it ends with a dialogue window "Export failed."
It worked once, and never again.
I've also tried doing the report programmatically with the following code:
fName = "C:\Schedule"
cryRpt.SetDataSource(ds)
Try
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = "E:\Schedule.pdf"
cryRpt.SetDataSource(ds)
CrExportOptions = cryRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
If which = "ScheduleToPDF" Then
.ExportFormatType = ExportFormatType.PortableDocFormat
CrDiskFileDestinationOptions.DiskFileName = _
"C:\Schedule Test.pdf"
fName = fName & ".pdf"
Else
CrDiskFileDestinationOptions.DiskFileName = _
"C:\Schedule Test.doc"
.ExportFormatType = ExportFormatType.WordForWindows
fName = fName & ".doc"
End If
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
cryRpt.Export()
MsgBox("Report " & fName & " Exported.")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
There is a long list of CrystalDecisions.Report... etc. ending at the line number (commented above) where the error occurs.
Note that if I try a direct export using:
cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\ScheduleExport.pdf")
it doesn't work, but the Error in File message is only one line long "Error in File" plus temp file name.
While:
cryRpt.ExportToDisk(ExportFormatType.WordForWindows, "C:\ScheduleExport.doc")
works. Exporting the report in Crystal Report format and loading it back using cryRpt.Load still result in Error in File.
Incidentally, the file name is a temp(followed by a lot of alphanumeric characters).rpt file.