BOS运行时-分页报表-干预引出excel页签名称原创
金蝶云社区-Howhy
Howhy
5人赞赏了该文章 179次浏览 未经作者许可,禁止转载编辑于2024年01月10日 10:03:30

分页报表支持引出所有页功能(注意维度多会占用较多应用服务器和数据库服务器资源),每一个维度的数据保存到一个excel页签内,有时候需要干预这个excel页签名称。


在23年1月份及以后版本,有个单独干预的插件方法

BeforeBuildExcelSheet

在之前版本,是通过修改dataset的各个datatable名称来进行干预

AfterGetAllPageDataSet

干预后,引出效果如下:

image.png

参考代码如下:

using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Report.PlugIn;
using Kingdee.BOS.Core.Report.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Kingdee.BOS.WebApi.Client;
using Kingdee.BOS.WebApi.FormService;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cloud.BOS.Support.Report
{
    [Description("分页报表干预引出的sheet名称")]
    [HotUpdate]
    public class MoveRptExportNamePlugin : AbstractSysReportPlugIn
    {
        /// <summary>
        /// 23年1月份标准补丁及以后版本用这个干预
        /// </summary>
        /// <param name="e"></param>
        public override void BeforeBuildExcelSheet(BeforeBuildExcelSheetEventArgs e)
        {
            //
            e.SheetName= string.Format("自定义sheet名称{0}", e.Position);
        }

        /// <summary>
        /// 23年1月份标准补丁之前干预方案
        /// </summary>
        /// <param name="e"></param>
        public override void AfterGetAllPageDataSet(AfterGetAllPageDataSetEventArgs e)
        {
            if(e.DS==null || e.DS.Tables==null || e.DS.Tables.Count==0) { return; }

            for (int i = 0; i < e.DS.Tables.Count; i++)
            {
                //修改dataTable名称,让引出名称变化
                e.DS.Tables[i].TableName = string.Format("自定义sheet名称{0}", i);
            }          
            
        }
    }
}


赞 5