繁体   English   中英

VB 6.0 Crystal Reports导出为PDF

[英]VB 6.0 Crystal Reports Export to PDF

我在将Crystal Reports文件报告为PDF格式时遇到问题。 我已经看过这里关于这个问题的所有其他问题,但它们似乎都没有解决我的问题。

这是我的代码:

Public Sub ExportReportToPDF(ReportObject As CRAXDRT.Report, ByVal filename As String, ByVal ReportTitle As String)

Dim objExportOptions As CRAXDRT.ExportOptions

ReportObject.ReportTitle = ReportTitle

With ReportObject
    .EnableParameterPrompting = False
    .MorePrintEngineErrorMessages = True
End With

Set objExportOptions = ReportObject.ExportOptions

With objExportOptions
    .DestinationType = crEDTDiskFile
    .DiskFileName = filename
    '.FormatType = crEFTExcel80Tabular
    '.FormatType = crEFTCommaSeparatedValues
    '.FormatType = crEFTExcel80
    '.FormatType = crEFTHTML32Standard
    '.FormatType = crEFTHTML40
    .FormatType = crEFTPortableDocFormat
    '.FormatType = crEFTRichText
    '.FormatType = crEFTText
    '.FormatType = crEFTWordForWindows

End With

ReportObject.Export False

End Sub

现在,除了PDF之外我还留下了其他选项只是为了展示它们,它们都被明确地注释掉了,但是如果我尝试任何其他格式,它输出就好了。 唯一不导出的格式是PDF。 它给了我错误:

运行时错误'-2147190908(80047784)':导出报告失败。

当我单击Debug时,它会在ReportObject.Export False行上突出显示。

另一方面,如果我这样做,用户选择了选项,我可以选择PDF,它仍然给我同样的错误。 谢谢您的帮助。

(感谢AVD的编码, 如何在Crystal Report中导出为PDF文件? )。

编辑:在完成Phillipe的回复之后,我正在逐步完成我的代码并注意到在将crEFTPortableDocFormat分配给FormatType之后,它会自动将“UXFPDF.DLL”分配给FormatDllName。 也许这是我的问题,有谁知道如何解决这个问题? 我试过重命名crxf_pdf.dll和u2fpdf.dll(我原来拥有的8.0版),但是没有用。

编辑:另一个发现是,当我在CRViewer91中启用导出选项(正确显示报告)并尝试通过此方法将其导出为pdf时,它不会出错。 但是,它会保存一个已损坏的文件,并且无法打开。

编辑:更多的研究。 CRViewer91似乎无法成功导出任何格式。 RTF和TXT返回空白文档,尝试打开时出现RPT错误。

编辑:我认为我的问题的一部分可能是我一直在使用8.0 CRAXRT.DLL,而我实际需要的是9.0。 我找到了一个9.0,现在如何使用它而不是旧的?

我猜'filename'值不起作用,因为文件夹不存在/文件名无效,或者因为您没有相应的权限来在此文件夹下创建文件。

你能尝试一些基本参数的代码,比如'filename =“c:\\ test.pdf”'吗?

我的最后一个猜测:导出为pdf格式的可能性需要一个特定的dll文件在crystal文件夹下(不需要注册,但需要在这里)。 你有crxf_pdf.dll文件吗?

编辑:

我的上一个问题:你能从Crystal GUI中发布PDF吗?

以下是必须与VB应用程序一起分发的水晶报表文件列表,如果有任何帮助:导出功能似乎链接到crxf _ * .dll文件

CRAnalyzer.dll
craxdrt.dll
crdb_ado.dll
crdeploy.reg
crheapalloc.dll
crqe.dll
crtowords_en.dll
crtslv.dll
crviewer.dll
crxf_html.dll
crxf_pdf.dll
crxf_rtf.dll
crxf_wordw.dll
crxf_xls.dll
cxlibw-1-6.dll
dbghelp.dll
exlate32.dll
ExportModeller.dll
GDIPLUS.DLL
Implode.dll
keycode.dll
msvcrt.dll
pageObjectModel.dll
querybuilder.dll
ReportRenderer.dll
riched20.dll
sscdlg.dll
sscsdk80.dll
u252000.dll
u25dts.dll
u25samp1.dll
u2dapp.dll
u2ddisk.dll
u2dmapi.dll
u2dpost.dll
u2fcr.dll
u2frdef.dll
u2frec.dll
u2fsepv.dll
u2ftext.dll
u2fxml.dll
u2l2000.dll
u2lcom.dll
u2ldts.dll
u2lexch.dll
u2lfinra.dll
ufmanager.dll
usp10.dll
webReporting.dll

我不确定导致所有错误的是什么,但是,我已经通过基本上从头开始一个新项目并仅包含必要的参考和组件来修复它。 我知道我遇到的一个问题(导致TLV错误)是CR9的CRAXDRT.dll在Windows \\ system32目录中,即使它引用了.dll,它也需要从Program Files \\ Common引用它Files \\ CrystalDecision ...目录,其中CR9的所有其他.dll都位于此目录中。

还需要进行一些次要的代码更改,这里是最终的代码,用于将我的导出为PDF。

Public Sub ExportReportToPDF(ReportObject As CRAXDRT.Report, ByVal filename As String, ByVal ReportTitle As String)

    Dim FormatDLLName As String

    ReportObject.ReportTitle = ReportTitle

    With ReportObject
        .EnableParameterPrompting = False
        .MorePrintEngineErrorMessages = True
    End With

    With ReportObject.ExportOptions
        .DestinationType = crEDTDiskFile
        .DiskFileName = filename
        '.FormatType = crEFTExcel80Tabular
        '.FormatType = crEFTCommaSeparatedValues
        '.FormatType = crEFTExcel80
        '.FormatType = crEFTHTML32Standard
        '.FormatType = crEFTHTML40
        .FormatType = crEFTPortableDocFormat
        '.FormatType = crEFTRichText
        '.FormatType = crEFTText
        '.FormatType = crEFTWordForWindows
    End With

    ReportObject.Export False

End Sub

我把那里注释掉的FormatTypes留给了那些发现这段代码有用的人。 菲利普,如果你想以某种方式“回答”这个,我很乐意为你提供一些代表,但是你提供的帮助却是如此。 我没有足够的代表来支持你的东西。

无论如何,谢谢你的帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM