/// <summary> /// 加载报表内容,前提条件: /// <para>报表模板名称</para> /// <para>确保查询参数完备</para> /// </summary> /// <param name="p_info">报表描述信息</param> public async void LoadReport(RptInfo p_info) { // 确保正确加载模板,参数完备 if (p_info == null || !await p_info.Init() || !p_info.IsParamsValid()) { return; } _excel.IsBusy = true; try { Info = p_info; if (p_info.ScriptObj != null && p_info.ScriptObj.View != this) { p_info.ScriptObj.View = this; } // 绘制报表内容 if (Info.Sheet == null) { RptRootInst inst = new RptRootInst(Info); await inst.Draw(); } using (_excel.Defer()) { _excel.Sheets.Clear(); // 设置分页线 _excel.PaperSize = new Size(Info.Root.PageSetting.ValidWidth, Info.Root.PageSetting.ValidHeight); // 添加报表页 var ws = Info.Sheet; if (ws != null) { // 应用外部可控制属性 ws.ColumnHeader.IsVisible = Info.Root.ViewSetting.ShowColHeader; ws.RowHeader.IsVisible = Info.Root.ViewSetting.ShowRowHeader; ws.ShowGridLine = Info.Root.ViewSetting.ShowGridLine; _excel.Sheets.Add(ws); } } } catch { Kit.Warn("报表绘制异常!"); } finally { _excel.IsBusy = false; } }
/// <summary> /// 打开新窗口显示报表 /// </summary> /// <param name="p_info">报表描述信息</param> /// <param name="p_winTitle"></param> /// <param name="p_icon">图标</param> public static async void Show(RptInfo p_info, string p_winTitle = null, Icons p_icon = Icons.折线图) { Throw.IfNull(p_info, _assertMsg); if (await p_info.Init()) { Kit.OpenWin(typeof(RptViewWin), string.IsNullOrEmpty(p_winTitle) ? p_info.Name : p_winTitle, p_icon, p_info); } else { Kit.Warn($"初始化报表模板[{p_info.Name}]出错!"); } }
/// <summary> /// 获取脚本自定义的报表查询面板 /// </summary> /// <param name="p_info"></param> /// <returns></returns> public virtual IRptSearchForm GetSearchForm(RptInfo p_info) { return(null); }