//记录共享列信息 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 int GetBeforeNotVisibleCount(DynmicColumns dynmicColumns, string columnName) { int count = 0; DynmicColumn dynmicColumn = dynmicColumns.FindDynmicColumn(columnName); if (dynmicColumn != null) { int endIndex = dynmicColumns.IndexOf(dynmicColumn); for (int i = 0; i < endIndex; i++) { if (!dynmicColumns[i].Visible) { count++; } } } return(count); }
//获取在合并范围内隐藏的共享列个数 public int GetNotVistbleCount(DynmicColumns dynmicColumns, string columnName, int columnSpan) { int count = 0; DynmicColumn dynmicColumn = dynmicColumns.FindDynmicColumn(columnName); if (dynmicColumn != null) { int startIndex = dynmicColumns.IndexOf(dynmicColumn); for (int i = startIndex; i < startIndex + columnSpan; i++) { //防止索引超出范围 if (dynmicColumns.Count > i && !dynmicColumns[i].Visible) { count++; } } } return(count); }