zoukankan      html  css  js  c++  java
  • [AX]AX2012 从代码运行SSRS报表

    在AX中SSRS除了从menu item运行,还可以从X++类运行,和AX3的runbasereport类类似,AX2012提供了SrsReportRunController、SrsReportDataContract、SrsReportRdlDataContract 、SrsReportDataContractUIBuilder、SrsPrintDestinationSettings 等类来运行SSRS报表,下面是一个运行vend.report报表结果保存到pdf文件的例子(转自http://axinternals.blogspot.com/2011/11/running-report-via-code-in-ax2012.html):

    static void RunSSRSReport(Args _args)
    {
        SrsReportRunController  reportRunController;
        Map                     queryContracts;
        MapEnumerator           mapEnum;
        Query                   query;
        QueryBuildRange         range;
        ;
    
        // Create the report run controller
        reportRunController = new SrsReportRunController();
        reportRunController.parmReportName('Vend.Report');
        reportRunController.parmLoadFromSysLastValue(false);
    
        // NB call to parmLoadFromSysLastValue must occur before any reference to
        // parmReportContract, otherwise the previous values (query ranges etc)
        // are defaulted in.
    
        // Set printer settings (print to file, format, filename, etc).
        reportRunController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
        reportRunController.parmReportContract().parmPrintSettings().overwriteFile(true);
        reportRunController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
        reportRunController.parmReportContract().parmPrintSettings().fileName('c:\\test.pdf');
    
        // Find/enumerate queries in the contract. The return from parmQueryContracts is
        // a map of type <ParameterName,Query(class)>
    
        queryContracts = reportRunController.parmReportContract().parmQueryContracts();
        mapEnum = queryContracts.getEnumerator();
        while(mapEnum.moveNext())
        {
            // Get the query and update the datasource as required
            query = mapEnum.currentValue();
            range = SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(VendTable)),fieldNum(VendTable,AccountNum));
            range.value('1*');
        }
    
        // Run the report
        reportRunController.runReport();
    
    }

    除了可以直接使用SrsReportRunController,AX也提供了很多它的扩展类,比如SrsPrintMgmtFormLetterController,从它扩展了类GiroPrintMgmtFormLetterController,而具体很多打印invoice的类比如SalesInvoiceController又继承自GiroPrintMgmtFormLetterController,使用这个类可以打印一组Invoice journal,具体如何使用可以参看系统自带的报表比如SalesInvoice。

    微软就报表编程模型提供了一份白皮书,这里下载:http://www.microsoft.com/en-us/download/details.aspx?id=27725

  • 相关阅读:
    django之session配置
    django之基于cookie和装饰器实现用户认证
    django之分页插件
    python小程序之并发连接
    django之模版的自定义函数
    django之母版的继承
    jQuery 模态对话框示例
    python学习笔记10 ----网络编程
    python 学习笔记9(面向对象)
    python 学习笔记8 (模块)
  • 原文地址:https://www.cnblogs.com/duanshuiliu/p/2658190.html
Copyright © 2011-2022 走看看