You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于InTouch HMI及.NET中SAP Crystal Reports使用的技术问询

SAP Crystal Reports 技术问题解答

问题1:最新版SAP Crystal Reports能否像Crystal Reports 8.5一样嵌入InTouch HMI应用,在运行时生成并导出报表至PDF?

不行。从Crystal Reports 2008(12.x)版本开始,SAP就移除了OCX控件支持,后续的最新版本也没有恢复可直接嵌入InTouch HMI的ActiveX/OCX控件能力。若要在InTouch HMI中集成报表功能,可采用间接方案:比如通过独立的报表服务进程生成PDF后,让InTouch调用打开该文件;或者基于.NET开发中间组件,通过InTouch的外部程序调用能力触发报表生成与导出。

问题2:能否通过.NET代码打开SAP Crystal Reports文件并导出至PDF?

可以。SAP官方提供了针对.NET的Crystal Reports SDK(Crystal Reports for .NET),支持加载.rpt文件、按需绑定数据源,并导出为PDF格式。

简单示例代码

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

// 加载目标报表文件
ReportDocument report = new ReportDocument();
report.Load(@"C:\Reports\YourReport.rpt");

// 可选操作:为报表绑定动态数据源(若报表需要)
// report.SetDataSource(yourDataSourceCollection);

// 配置导出参数
ExportOptions exportOptions = new ExportOptions();
exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;

DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
diskOpts.DiskFileName = @"C:\Exports\FinalReport.pdf";
exportOptions.DestinationOptions = diskOpts;

// 执行导出操作
report.Export(exportOptions);

// 释放资源
report.Close();
report.Dispose();

注意:项目需引用SAP Crystal Reports的.NET程序集,同时部署环境要安装对应的Crystal Reports运行时组件。

内容的提问来源于stack exchange,提问作者devman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 14:22:02