Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a dataset that I fill manually from a database using LINQ. I display the report using the normal functions as follows.

VB
Public objRpt As New ReportDocument
Dim ds As New rptDataSet   'The empty dataset I created 
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 'Whatever


Dim r As DataRow    'Holds Material data
Dim rs As DataRow   'Holds schedule data
Dim cd As DataRow   'Holds worksheet data

For each dr In sc
'Fill dataset datarows r, rs, cd
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:

VB
fName = "C:\Schedule"
cryRpt.SetDataSource(ds) 'ds = the created and filled dataset above
'cryRpt = New ReportDocument
'cryRpt.Load("ScheduleTest.rpt")
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 'Export to Word
             fName = fName & ".doc"
      End If
      .DestinationOptions = CrDiskFileDestinationOptions
      .FormatOptions = CrFormatTypeOptions
    End With

    cryRpt.Export()  'Hangs here on pdf export. Works with .doc, .xls, .rtf, .htm
    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:
VB
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:
VB
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.
Posted
Updated 8-Jul-14 15:25pm
v4

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900