套打.二开案例.简单账表按照范围生成导出文件

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

套打.二开案例.简单账表按照范围生成导出文件

【场景】简单账表按照范围生成导出文件 【案例】自定义账表,报表取数逻辑为按天计算;实现点击一个菜单,自动导出一个月的套打导出文件 (0)自定义报表、报表过滤 ![image.webp](/download/0100071a680c48af4d3ab649f6456c4caa95.webp) ![image.webp](/download/01008388feeb985f47539afdb80374fc23c0.webp) ```csharp using Kingdee.BOS.App.Data; using Kingdee.BOS.Contracts.Report; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.NotePrint; using Kingdee.BOS.Core.Report; using Kingdee.BOS.Core.Report.PlugIn; using Kingdee.BOS.Util; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DynamicFormPlugIn.Report { [Kingdee.BOS.Util.HotUpdate] public class ReportServicePlugIn_Sample : SysReportBaseService { public override void Initialize() { } public override ReportHeader GetReportHeaders(IRptParams filter) { ReportHeader rptHeader = new ReportHeader(); rptHeader.AddChild("F_BHR_Text", new Kingdee.BOS.LocaleValue("单据编号")); rptHeader.AddChild("F_BHR_Text1", new Kingdee.BOS.LocaleValue("文本")); return rptHeader; } public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName) { var cursomFilter = filter.FilterParameter.CustomFilter; DateTime date = DateTime.Now; if(cursomFilter.DynamicObjectType.Properties.ContainsKey("F_BHR_Date")) { date = Convert.ToDateTime(cursomFilter["F_BHR_Date"]); } StringBuilder stringBuilder = new StringBuilder(); KSQL_SEQ = string.Format(KSQL_SEQ, "FID"); //stringBuilder.AppendFormat("select top 10 FID, FQty, {0} into {1} from t_pur_poorderentry", KSQL_SEQ, tableName); //增加精度 stringBuilder.AppendFormat("select top 10 FID, FBillNo as F_BHR_Text, '{2}' as F_BHR_Text1, {0} into {1} from t_pur_poorder where fbillno <> ' '", KSQL_SEQ, tableName, date.ToString("yyyy-MM-dd")); DBUtils.Execute(this.Context, stringBuilder.ToString()); } } } ``` (1)报表自定义菜单,表单插件实现动态切换条件和生成pdf ![image.webp](/download/01008000455e4dfe492a93cb60f287e69312.webp) ```csharp using Kingdee.BOS.App.Data; using Kingdee.BOS.Contracts.Report; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.NotePrint; using Kingdee.BOS.Core.Report; using Kingdee.BOS.Core.Report.PlugIn; using Kingdee.BOS.Util; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DynamicFormPlugIn.Report { [Kingdee.BOS.Util.HotUpdate] public class ReportViewPlugIn_ExportMultiFile : AbstractSysReportPlugIn { private string billid = ""; private string templateId = "6129c2df-71cd-4a1b-9ea0-ca8fa418826f"; public override void BarItemClick(BarItemClickEventArgs e) { if (!string.Equals(e.BarItemKey, "tb_ExportMultiFile", StringComparison.OrdinalIgnoreCase)) return; //当前月第一天 DateTime fromDate = DateTime.Now.AddDays(1 - DateTime.Now.Day); //下一个月第一天 //DateTime toDate = fromDate.AddMonths(1); DateTime toDate = fromDate.AddDays(5); StringBuilder msg = new StringBuilder(); //导出每一天的套打文件 while(fromDate < toDate) { string filePath = ExportCur(fromDate); msg.AppendLine(filePath); fromDate = fromDate.AddDays(1); } if (msg.Length > 0) { this.View.ShowMessage(msg.ToString()); } } /// <summary> /// 导出当前的文件 /// </summary> private string ExportCur(DateTime curDate) { /* * 根据当前条件调整过滤参数 */ var filter = this.SysReportView.Model.FilterParameter; if (filter == null) return string.Empty; filter.CustomFilter["F_BHR_Date"] = curDate; //删除临时表,重新生成 this.SysReportView.Model.DropALLTable(); PrintExportInfo printExportInfo = new PrintExportInfo() { BillIds = new List<string>() { billid }, TemplateIds = new List<string>() { templateId }, ExportType = ExportType.ByPage, FileType = ExportFileType.PDF, FilePath = PathUtils.GetPhysicalPath("TempFilePath", string.Format("自定义导出-{0}.pdf", curDate.ToString("yyyyMMdd"))), PageId = this.View.PageId, FormId = this.View.BillBusinessInfo.GetForm().Id, }; //导出文件 IDynamicFormViewService viewService = this.View as IDynamicFormViewService; viewService.ExportNotePrint(printExportInfo); /* * 对应的文件生成位置 */ if (printExportInfo.ExportFileInfos == null || !printExportInfo.ExportFileInfos.Any()) return string.Empty; return printExportInfo.ExportFileInfos[0].FilePath; } } } ``` 【案例】 效果,生成N个pdf导出文件,每一个都是按照过滤数据生成的 ![20231023 1519.webp](/download/010086e115d72f274015870688056d2d1638.webp)

这个怎么解决大佬


老师,很多简单账表的字段是动态生成的,不适用于套打模板,需要使用引出功能,这个时候,怎么去调用引出的逻辑呢?

套打.二开案例.简单账表按照范围生成导出文件

【场景】简单账表按照范围生成导出文件【案例】自定义账表,报表取数逻辑为按天计算;实现点击一个菜单,自动导出一个月的套打导出文件(0)...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息