Crystal Reports 13:如何导出到XLSX

2020-09-19 01:09发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)您好,SAP-Crystal R...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


您好,SAP-Crystal Reports支持团队,

我仍然尝试将数据导出为XLSX格式。 我的(C ++)程序作为服务运行,并且仅导出到磁盘文件(主要是PDF)。

我的安装如下:

操作系统:Windows 10 Pro
IDE:Microsoft Visual Studio 2010,版本10.0.40219.1 SP1Rel
Microsoft .NET Framework 4.7.02558 SP1Rel

SAP Crystal Reports,用于Microsoft Visual Studio的版本13.0.22.2668

我的代码段如下:

#using

#using
#using
#using
#using

使用命名空间CrystalDecisions :: Shared;
使用命名空间CrystalDecisions :: ReportSource;
使用命名空间CrystalDecisions :: CrystalReports:Engine;
使用命名空间CrystalDecisions :: ReportAppServer :: ReportDefModel;

...

布尔CVerarbCR :: ExportSrv(...)

{

...

CrystalDecisions :: ReportAppServer :: ReportDefModel :: ReportDocument ^ RASrptDoc = gcnew CrystalDecisions :: ReportAppServer :: ReportDefModel :: ReportDocument();
CrystalDecisions :: ReportAppServer :: ReportDefModel :: DataOnlyExcelExportFormatOptions ^ RASXLXSExportOpts =
CrystalDecisions :: ReportAppServer :: ReportDefModel :: DataOnlyExcelExportFormatOptions();
RASXLXSExportOpts =(DataOnlyExcelExportFormatOptions ^)RASrptDoc-> get_SavedExportOptions(CrystalDecisions :: ReportAppServer :: ReportDefModel :: CrReportExportFormatEnum:C> 36.6;
RASXLXSExportOpts-> ExportObjectFormatting = true;
RASXLXSExportOpts-> ExportImages = false;
RASXLXSExportOpts-> UseWorksheetFunctionsForSummaries = false;
RASXLXSExportOpts-> MaintainRelativeObjectPosition => true;
RASXLXSExportOpts-> ExportPageHeaderAndFooter = false;
RASXLXSExportOpts-> SimplifyPageHeaders = true; RASXLXSExportOpts-> ShowGroupOutlines = false;

CrystalDecisions :: ReportAppServer :: ReportDefModel :: ExportOptions ^ exportOpts1 = gcnew CrystalDecisions :: ReportAppServer :: ReportDefModel :: ExportOptions();
exportOpts1-> ExportFormatType = CrystalDecisions :: ReportAppServer :: ReportDefModel :: CrReportExportFormatEnum :: crReportExportFormatXLSX;
exportOpts1-> FormatOptions = RASXLXSExportOpts;

RASrptDoc-> PrintOutputController.ExportEx(exportOpts1).Save(strReportPathAndName,true);

...

我在这里遇到错误:

get_SavedExportOptions不是

的元素

CrystalDecisions :: ReportAppServer :: ReportDefModel :: ReportDocument

PrintOutputController不是

的元素

CrystalDecisions :: ReportAppServer :: ReportDefModel :: ReportDocument

在哪里可以找到ReportAppServer的API? 请注意,链接 help.sap.com/businessobject/ product_guides/sapCRVS2010/en/rasnet10_api_en.zip 不再有效!

预先感谢

Stefan Grasse(VAB GmbH)

4条回答
小c菟菟
2020-09-19 01:23 .采纳回答

史蒂芬,你好

尝试获取获取的已保存选项,只有在将它们保存在CR Designer中后,它们才会存在,因此如果它们不存在,则可以忽略它们。


这有效:

使用命名空间CrystalDecisions :: Shared;
     使用命名空间CrystalDecisions :: CrystalReports :: Engine;
     使用命名空间CrystalDecisions :: ReportAppServer :: ClientDoc;
     使用命名空间CrystalDecisions :: ReportAppServer :: ReportDefModel;
     使用命名空间CrystalDecisions :: ReportAppServer :: CommonObjectModel;
     使用命名空间CrystalDecisions :: ReportAppServer :: Controllers;

     使用命名空间CrystalDecisions :: ReportAppServer;
     使用命名空间CrystalDecisions :: ReportAppServer :: CommonControls;
     使用命名空间CrystalDecisions :: ReportAppServer :: CommLayer;
     使用命名空间CrystalDecisions :: ReportAppServer :: ObjectFactory;
     使用命名空间CrystalDecisions :: ReportAppServer :: Prompting;
     使用命名空间CrystalDecisions :: ReportAppServer :: DataSetConversion;
     使用命名空间CrystalDecisions :: ReportAppServer :: DataDefModel;
     使用命名空间CrystalDecisions :: ReportSource;
     使用命名空间CrystalDecisions :: Windows :: Forms;
     使用命名空间CrystalDecisions :: ReportAppServer :: XmlSerialize;



             CrystalDecisions :: CrystalReports :: Engine :: ReportDocument ^ rpt = gcnew CrystalDecisions :: CrystalReports :: Engine :: ReportDocument();
             CrystalDecisions :: ReportAppServer :: ClientDoc :: ISCDReportClientDocument ^ rptClientDoc;

             String ^ sampleReportPath = gcnew String(" C:\\ reports \\ DecimalSeparator.rpt");

             rpt-> Load(sampleReportPath);
             rptClientDoc = rpt-> ReportClientDocument;

             CrystalDecisions :: ReportAppServer :: ReportDefModel :: DataOnlyExcelExportFormatOptions ^ RASXLXSExportOpts = gcnew CrystalDecisions :: ReportAppServer :: ReportDefModel :: DataOnlyExcelExportFormatOptions();
            /////RASXLXSExportOpts =(DataOnlyExcelExportFormatOptions ^)RASrptDoc-> get_SavedExportOptions(CrystalDecisions :: ReportAppServer :: ReportDefModel :: CrReportExportFormatEnum :: crReportExportFormatXLSX);
             RASXLXSExportOpts-> ConstantColWidth = 36.6;
             RASXLXSExportOpts-> ExportObjectFormatting = true;
             RASXLXSExportOpts-> ExportImages = false;
             RASXLXSExportOpts-> UseWorksheetFunctionsForSummaries = false;
             RASXLXSExportOpts-> MaintainRelativeObjectPosition = true;
             RASXLXSExportOpts-> MaintainColumnAlignment = true;
             RASXLXSExportOpts-> ExportPageHeaderAndFooter = false;
             RASXLXSExportOpts-> SimplifyPageHeaders = true;
             RASXLXSExportOpts-> ShowGroupOutlines = false;

             CrystalDecisions :: ReportAppServer :: ReportDefModel :: ExportOptions ^ exportOpts1 = gcnew CrystalDecisions :: ReportAppServer :: ReportDefModel :: ExportOptions();
             exportOpts1-> ExportFormatType = CrystalDecisions :: ReportAppServer :: ReportDefModel :: CrReportExportFormatEnum :: crReportExportFormatXLSX;
             exportOpts1-> FormatOptions = RASXLXSExportOpts;

             String ^ strReportPathAndName =" C:\\ reports \\ DecimalSeparator.xlxs";

             rptClientDoc-> PrintOutputController-> ExportEx(exportOpts1)-> Save(strReportPathAndName,true);
            
            //将查看器设置为要预览的报表对象。 这必须做
            //设置完所有数据库登录后。
             crystalReportViewer1-> ReportSource = rpt; 

一周热门 更多>