直接上代碼!css
using Kingdee.BOS.Contracts; using Kingdee.BOS.Core; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Report; using Kingdee.BOS.Core.ReportFilter; using Kingdee.BOS.Model.CommonFilter; using Kingdee.BOS.Model.ReportFilter; using Kingdee.BOS.ServiceHelper; ISysReportService sysReporSservice = ServiceFactory.GetSysReportService(this.Context); IPermissionService permissionService = ServiceFactory.GetPermissionService(this.Context); var filterMetadata = FormMetaDataCache.GetCachedFilterMetaData(this.Context);//加載字段比較條件元數據。 var reportMetadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, "AR_AgingAnalysis");//加載應收款帳齡分析表元數據。 var reportFilterMetadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, "AR_AgingAnalysisFilter");//加載應收款帳齡分析表過濾條件元數據。 var reportFilterServiceProvider = reportFilterMetadata.BusinessInfo.GetForm().GetFormServiceProvider(); var model = new SysReportFilterModel(); model.SetContext(this.Context, reportFilterMetadata.BusinessInfo, reportFilterServiceProvider); model.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id; model.FilterObject.FilterMetaData = filterMetadata; model.InitFieldList(reportMetadata, reportFilterMetadata); model.GetSchemeList(); var entity = model.Load("57fc5b64cc45d7");//過濾方案的主鍵值,可經過該SQL語句查詢獲得:SELECT * FROM T_BAS_FILTERSCHEME var filter = model.GetFilterParameter(); IRptParams p = new RptParams(); p.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id; p.StartRow = 1; p.EndRow = int.MaxValue;//StartRow和EndRow是報表數據分頁的起始行數和截至行數,通常取全部數據,因此EndRow取int最大值。 p.FilterParameter = filter; p.FilterFieldInfo = model.FilterFieldInfo; p.BaseDataTempTable.AddRange(permissionService.GetBaseDataTempTable(this.Context, reportMetadata.BusinessInfo.GetForm().Id)); using (DataTable dt = sysReporSservice.GetData(this.Context, reportMetadata.BusinessInfo, p)) { //dt就是報表數據,接下來就是你發揮的時間。 } ServiceFactory.CloseService(sysReporSservice); ServiceFactory.CloseService(permissionService);