//记录共享列信息 private void InitDynmicColumn(Report report, DataTable dt, ReportData data) { dynmicColumns = new DynmicColumns(report); if (dynmicColumns.Count > 0) { currReport = new Report(report.DesrcName, report.DesrcLevel); currReport.RptFilePath = report.RptFilePath; currReport.ReadRPT(); currReport.Data = data; currReport.DataValid = true; int index = currReport.Columns.IndexOf(dynmicColumns[dynmicColumns.Count - 1].ColName); for (int i = dt.Columns.Count - 1; i >= 0; i--) { string[] strs = dt.Columns[i].ColumnName.Split('_'); if (strs.Length == 2 && Function.IsNumber(strs[1])) { string name = strs[0]; DynmicColumn dynmicColumn = dynmicColumns.FindDynmicColumn(name); if (dynmicColumn.Visible) { ReportColumn newReportColumn = report.Columns[name].Clone(); newReportColumn.ColumnName = dt.Columns[i].ColumnName; //index = report.Columns.IndexOf(name); currReport.Columns.Insert(index + 1, newReportColumn); } } } } }
public void NewReport() { report = new Report(this.reportName, this.level); report.RptFilePath = this.reportSrc; string fileName = Path.GetFileName(ReportSrc); //用户自定义的报表不需要重定位RPT路径 if (ReportSrc.Contains("用户自定义")) { report.ReadRPT(); } else { report.ReadRPT(fileName); } }
public void NewReport(MutliProjectManager projectManager) { report = new Report(this.reportName, this.level); //report.DocPath = reportSrc; report.PropertyValid = true; report.ReadRPT("report_WORD报表模板.rpt"); //report.DllPath = Path.Combine(Function.ReportFolder, "report_项目工程宏变量列表.dll"); report.PropertyValid = true; report.InitReportData(projectManager, -1); }
public ReportDrawStruct GetReportStruct(string rptFilePath, DataTable dt, Dictionary <string, int> dicMergeColInfo) { using (Report report = new Report()) { report.RptFilePath = rptFilePath; report.ReadRPT(); report.Attributes.GrainDirection = 0; ReportData reportData = new ReportData(report); reportData.InitReportData(dt); report.Data = reportData; reportData.MergeBlack(report, dicMergeColInfo); report.DataValid = true; report.RaiseDataChanged(); report.RaisePropertyChanged(); return(report.WholeDrawStruct); } }
public void ViewReport(string rptFilePath, DataTable dt, Dictionary <string, int> dicMergeColInfo) { Report report = new Report(); report.RptFilePath = rptFilePath; report.ReadRPT(); report.Attributes.GrainDirection = 0; ReportData reportData = new ReportData(report); reportData.InitReportData(dt); report.Data = reportData; reportData.MergeBlack(report, dicMergeColInfo); report.DataValid = true; report.RaiseDataChanged(); report.RaisePropertyChanged(); Repaint(report); currReport = report; }
public ReportCatlog() { report = new Report(); report.ReadRPT("目录.rpt"); InitTableColumn(); }
private void SetReportProperty(TreeListNodes nodes) { foreach (TreeListNode node in nodes) { if (node.Checked && node["src"].ToString() != "") { string rptPath = string.Empty; if (!Function.DebugMode) { rptPath = Function.UserReportFolder + node["src"]; if (!System.IO.File.Exists(rptPath)) { string sysRptPath = Function.ReportFolder + node["src"]; if (System.IO.File.Exists(sysRptPath)) { System.IO.File.Copy(sysRptPath, rptPath); } } } else { rptPath = Function.ReportFolder + node["src"]; } if (!System.IO.File.Exists(rptPath)) { continue; } Report report = new Report(); report.RptFilePath = rptPath; report.ReadRPT(); string fontName = ddlFontName.Text == "默认" ? report.Attributes.Font.Name : ddlFontName.Text; float fontSize = ddlFontSize.Text == "默认" ? report.Attributes.Font.Size : Math.Abs(float.Parse(ddlFontSize.Text)); report.Attributes.Font = new Font(fontName, fontSize); foreach (ReportColumn column in report.Columns) { column.Attibutes.Font = new Font(fontName, fontSize, report.Attributes.Font.Style); } if (ddlMutliRowHeight.Text != "默认") { report.Attributes.RowHeiht = float.Parse(ddlMutliRowHeight.Text.Replace("倍行高", "")); } if (checkBrifeReport.CheckState != CheckState.Indeterminate) { report.Attributes.PrintStyle.IsBrifeStyle = checkBrifeReport.Checked; } Texts titleTexts = report.Texts.GetTextsBy(1); foreach (Text text in report.Texts) { string textFontName = string.Empty; string textFontSize = string.Empty; FontStyle style = new FontStyle(); bool bold = false; switch (text.BandIndex) { case 1: textFontName = ddlTitleFontName.Text; textFontSize = ddlTitleFontSize.Text; if (checkTitleBold.CheckState == CheckState.Indeterminate) { bold = text.Attribute.Font.Bold; } else { bold = checkTitleBold.Checked; } //在bandIndex = 1的区域中,字体最大的归为标题区,较小字体的归为表头区 foreach (Text titleText in titleTexts) { if (text.Attribute.Font.Size < titleText.Attribute.Font.Size) { textFontName = ddlHeadFontName.Text; textFontSize = ddlHeadFontSize.Text; if (checkHeadBold.CheckState == CheckState.Indeterminate) { bold = text.Attribute.Font.Bold; } else { bold = checkHeadBold.Checked; } } } break; case 2: textFontName = ddlHeadFontName.Text; textFontSize = ddlHeadFontSize.Text; if (checkHeadBold.CheckState == CheckState.Indeterminate) { bold = text.Attribute.Font.Bold; } else { bold = checkHeadBold.Checked; } break; case 3: textFontName = ddlBodyFontName.Text; textFontSize = ddlBodyFontSize.Text; if (checkBodyBold.CheckState == CheckState.Indeterminate) { bold = text.Attribute.Font.Bold; } else { bold = checkBodyBold.Checked; } break; case 4: textFontName = ddlSummaryFontName.Text; textFontSize = ddlSummaryFontSize.Text; if (checkSummaryBold.CheckState == CheckState.Indeterminate) { bold = text.Attribute.Font.Bold; } else { bold = checkSummaryBold.Checked; } break; case 5: textFontName = ddlFootFontName.Text; textFontSize = ddlFootFontSize.Text; if (checkFootBold.CheckState == CheckState.Indeterminate) { bold = text.Attribute.Font.Bold; } else { bold = checkFootBold.Checked; } break; } if (bold) { style |= FontStyle.Bold; } if (text.Attribute.Font.Italic) { style |= FontStyle.Italic; } if (text.Attribute.Font.Underline) { style |= FontStyle.Underline; } textFontName = textFontName == "默认" ? text.Attribute.Font.Name : textFontName; textFontSize = textFontSize == "默认" ? text.Attribute.Font.Size.ToString() : textFontSize; try { text.Attribute.Font = new Font(textFontName, Math.Abs(float.Parse(textFontSize)), style); } catch (Exception e) { Function.Alert(String.Format("批量修改字体设置错误,信息:{0}", e), "错误"); } } if (!string.IsNullOrEmpty(txtTopMargin.Text)) { report.Attributes.Margin.Top = ConvertUtil.GetBoundary(txtTopMargin.Text); } if (!string.IsNullOrEmpty(txtBottomMargin.Text)) { report.Attributes.Margin.Bottom = ConvertUtil.GetBoundary(txtBottomMargin.Text); } if (!string.IsNullOrEmpty(txtLeftMargin.Text)) { report.Attributes.Margin.Left = ConvertUtil.GetBoundary(txtLeftMargin.Text); } if (!string.IsNullOrEmpty(txtRightMargin.Text)) { report.Attributes.Margin.Right = ConvertUtil.GetBoundary(txtRightMargin.Text); } report.WriteRpt(false); } SetReportProperty(node.Nodes); } }
//刷新当前报表节点 public void ReferenceFocusedNode() { if (ReportList.FocusedNode == null) { return; } //InitMutliProjectStruct(); string fileName = ReportList.FocusedNode.GetValue("src").ToString(); if (!string.IsNullOrEmpty(fileName)) { string descrName = ReportList.FocusedNode.GetValue("name").ToString(); int descrLevel = 0; if (!int.TryParse(ReportList.FocusedNode.GetValue("level").ToString(), out descrLevel)) { Function.Alert("报表相关XML的LEVEL数据无效!", "提示"); } curReport = new Report(descrName, descrLevel); curReport.ReadRPT(fileName); //用户报表 string userFilePath = curReport.RptFilePath; if (userFilePath.StartsWith(Function.UserReportFolder)) { string sysFilePath = Function.ReportFolder + fileName; if (File.GetLastWriteTime(sysFilePath) > File.GetLastWriteTime(userFilePath)) { //系统报表新于用户报表,更新用户报表,保留原有列显示信息和参数设置 Report newReport = new Report(descrName, descrLevel); newReport.RptFilePath = sysFilePath; newReport.ReadRPT(); foreach (ReportColumn column in newReport.Columns) { ReportColumn col = curReport.Columns.Find(column.ColumnName); if (col != null) { column.Attibutes.PrintStyle.NoPrint = col.Attibutes.PrintStyle.NoPrint; } } curReport = newReport; curReport.RptFilePath = userFilePath; curReport.WriteRpt(false); } } arguments.Enabled = (Function.ProfileInt(curReport.RptFilePath, "报表参数", "enabled", 0) == 1 && Function.ProfileInt(curReport.RptFilePath, "报表参数", "count", 0) != 0); //初始化预览方式数据 //curReport.InitReportData(projectDataManager, 0); Dictionary <string, object> dict = new Dictionary <string, object>(); dict["生成方式"] = "预览"; curReport.InitReportData(projectDataManager.ProjectData as DataSet, dict); Repaint(); } else { curReport = null; ReportMode.Image = null; } }