读取报表工具类

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

读取报表工具类

using Kingdee.BOS;

using Kingdee.BOS.Contracts;

using Kingdee.BOS.Core.CommonFilter;

using Kingdee.BOS.Core.Report;

using Kingdee.BOS.Model.ReportFilter;

using Kingdee.BOS.ServiceFacade;

using Kingdee.BOS.ServiceHelper;

using System;

using System.Data;

using System.Text;


namespace Kingdee.JY.Tools.Report

{

    /// <author>Rong</author>

    /// <createDate></createDate>

    /// <alteration>读取报表工具</alteration>

    public class ReportUtils

    {

        /// <summary>

        /// 获取报表模型

        /// </summary>

        /// <param name="ctx">上下文</param>

        /// <param name="reportFormId">报表业务标识</param>

        /// <param name="reportFilterFormId">报表过滤框业务标识</param>

        /// <returns></returns>

        public static SysReportFilterModel GetReportModel(Context ctx, string reportFormId, string reportFilterFormId)

        {

            ISysReportService sysReporSservice = ServiceFactory.GetSysReportService(ctx);

            var filterMetadata = FormMetaDataCache.GetCachedFilterMetaData(ctx);

            var reportMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, reportFormId);

            var reportFilterMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, reportFilterFormId);

            var reportFilterServiceProvider = reportFilterMetadata.BusinessInfo.GetForm().GetFormServiceProvider();

            SysReportFilterModel model = new SysReportFilterModel();

            model.SetContext(ctx, reportFilterMetadata.BusinessInfo, reportFilterServiceProvider);

            model.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id;

            model.FilterObject.FilterMetaData = filterMetadata;

            model.InitFieldList(reportMetadata, reportFilterMetadata);


            return model;

        }


        /// <summary>

        /// 报表查询

        /// </summary>

        /// <param name="ctx">上下文</param>

        /// <param name="model">报表过滤模型</param>

        /// <param name="FilterParameter">过滤参数</param>

        /// <param name="reportFormId">报表业务标识</param>

        /// <param name="reportFilterFormId">报表过滤框业务标识</param>

        /// <param name="reportType">报表类型:(1.简单 2.树形 3.分页 4.透视)</param>

        /// <returns></returns>

        public static string GetReportInfo(Context ctx, SysReportFilterModel model, FilterParameter FilterParameter, string reportFormId, string reportFilterFormId, string reportType)

        {

            ISysReportService sysReporSservice = ServiceFactory.GetSysReportService(ctx);

            var reportMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, reportFormId);

            var reportFilterMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, reportFilterFormId);

            IRptParams p = new RptParams();

            p.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id;

            p.StartRow = 1;

            p.EndRow = int.MaxValue;//StartRow和EndRow是报表数据分页的起始行数和截至行数,一般取所有数据,所以EndRow取int最大值。

            p.FilterParameter = FilterParameter;

            p.FilterFieldInfo = model.FilterFieldInfo;

            MoveReportServiceParameter param = new MoveReportServiceParameter(ctx, reportMetadata.BusinessInfo, Guid.NewGuid().ToString(), p);


            SerializerProxy serialHelper = new SerializerProxy(MessageFormats.Json, UTF8Encoding.UTF8, false, string.Empty, true);

            DataTable dt = new DataTable();


            switch (reportType)

            {

                case "1":

                    IReportData reportData = sysReporSservice.GetReportData(param);

                    dt = reportData.DataSource;

                    break;


                case "2":

                    ITreeReport treeReport = sysReporSservice.GetTreeReportData(param);

                    dt = treeReport.DataSource;

                    break;


                case "3":

                    IMoveReport moveReport = sysReporSservice.GetListAndReportData(param);

                    dt = moveReport.DataSource;

                    break;


                case "4":

                    IPivotGridReport pivotGridReport = sysReporSservice.GetCrossReportData(param);

                    dt = pivotGridReport.DataSource;

                    break;

            }


            return serialHelper.Serialize(dt);

        }

    }

}



可以发个参数示例吗


用的类似方法在7.5版本正常,升级8.0后就不行了。


你好,麻烦问一下P这个参的传值是怎么定义的,有取值样例嘛

读取报表工具类

using Kingdee.BOS;using Kingdee.BOS.Contracts;using Kingdee.BOS.Core.CommonFilter;using Kingdee.BOS.Core.Report;using Kingdee...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息