转换为PDF时,VS 2008 Crystal Reports文件出错 [英] VS 2008 Crystal Reports Error in File when converting to PDF
问题描述
我有一个数据集,我使用LINQ从数据库手动填充。我使用以下常规功能显示报告。
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 '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()
到目前为止,一切都很完美。但是,如果我使用menu命令进行转换,它可以在除pdf之外的每种格式下工作,弹出错误并且不会写入pdf文件。
错误是文件C中的错误:\ temp_xxxx_.rpt
操作尚未实现。
然后它以对话窗口结束导出失败。
它工作过一次,再也没有。
我也尝试过该报告以编程方式使用以下代码:
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) '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
有很长的CrystalDecisions.Report列表...等于发生错误的行号(上面评论)。
请注意,如果我尝试直接导出使用:
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")
有效。以Crystal Report格式导出报表并使用cryRpt.Load将其加载回来仍然会导致文件错误。
顺便提一下,文件名是temp(后跟一个很多字母数字字符.rpt文件。
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.
推荐答案
使用此课程节省时间
Crystal Reports助手类 [ ^ ]
这个是给Web的
如何在按钮上导出Crystal报表单击PDF,Excel,Word, HTML,Rtf在ASP.NET C#中。 [ ^ ]
Use this class to save your time
Crystal Reports helper class[^]
This one is for Web
How to Export Crystal Report on Button Click in to PDF, Excel, Word, HTML, Rtf in ASP.NET C#.[^]
这篇关于转换为PDF时,VS 2008 Crystal Reports文件出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!