public SubTitleCmdArgs(RptItemBase p_parent, RptMtxSubtitle p_title = null, int p_newSpan = -1) { Parent = p_parent; SubTitle = p_title; NewSpan = p_newSpan; InitData(); }
/// <summary> /// 获取最大ID的转换方法 /// </summary> /// <param name="p_item"></param> /// <param name="p_preName"></param> /// <returns></returns> int GetValidInt(RptItemBase p_item, string p_preName) { if (p_item is RptMtxSubtotal) { RptMtxSubtotal total = p_item as RptMtxSubtotal; if (total.Item.Val.Length < p_preName.Length) { return(0); } int id = 0; if (int.TryParse(total.Item.Val.Substring(p_preName.Length), out id)) { return(id); } return(0); } else { RptMtxSubtitle title = p_item as RptMtxSubtitle; if (title.Item.Val.Length < p_preName.Length) { return(0); } int id = 0; if (int.TryParse(title.Item.Val.Substring(p_preName.Length), out id)) { return(id); } return(0); } }
/// <summary> /// 小计参数 /// </summary> /// <param name="p_parent">小计所属上级</param> /// <param name="p_total">当前操作的小计</param> /// <param name="p_newSpan"></param> public SubTotalCmdArgs(RptItemBase p_parent, RptMtxSubtotal p_total = null, int p_newSpan = -1) { Parent = p_parent; SubTotal = p_total; NewSpan = p_newSpan; InitData(); }
public RptMtxSubtitle(RptItemBase p_parent) { _parent = p_parent; Item = new RptText(this); SubTitles = new List <RptMtxSubtitle>(); // 所占行数/列数 _data.AddCell("span", 1); }
public RptMatrixInst(RptItemBase p_item) : base(p_item) { _cellInsts = new List <RptTextInst>(); RowHeaderInsts = new List <RptMtxHeaderInst>(); ColHeaderInsts = new List <RptMtxHeaderInst>(); _rowUsed = new List <int>(); _colUsed = new List <int>(); }
/// <summary> /// 输出单列表头表尾可重复表格布局 /// </summary> void OutputTable() { _region.RowSpan = 0; _data.Current = 0; RptRootInst root = Inst; RptRegion region; if (_header != null) { _header.Output(); region = _header.Region; _region.RowSpan = region.Row + region.RowSpan - _region.Row; } root.VerPageBegin += OnPageBegin; root.VerPageEnd += OnPageEnd; RptTable tbl = _item as RptTable; if (tbl.Footer != null && tbl.RepeatFooter) { root.TblFooterHeight = tbl.Footer.Height; } foreach (RptTblPartInst inst in _rows) { _curPart = inst; RptItemBase item = inst.Item; region = new RptRegion( _region.Row + _region.RowSpan, _region.Col, item.RowSpan, item.ColSpan); inst.Region = region; inst.Output(); _region.RowSpan = region.Row + region.RowSpan - _region.Row; } _curPart = null; root.TblFooterHeight = 0.0; root.VerPageBegin -= OnPageBegin; root.VerPageEnd -= OnPageEnd; if (_footer != null) { RptItemBase item = _footer.Item; region = new RptRegion( _region.Row + _region.RowSpan, _region.Col, item.RowSpan, item.ColSpan); _footer.Region = region; _footer.Output(); _region.RowSpan = region.Row + region.RowSpan - _region.Row; } _data.Current = 0; }
public RptMtxHeaderInst(RptItemBase p_item) : base(p_item) { RptMatrix mat = p_item.Parent as RptMatrix; HeaderType = p_item is RptMtxRowHeader ? RptMtxHeaderType.Row : RptMtxHeaderType.Col; Visible = HeaderType == RptMtxHeaderType.Row ? !mat.HideRowHeader : !mat.HideColHeader; TxtInsts = new List <RptTextInst>(); Filter = new Dictionary <string, string>(); }
public RptMtxSubtotal(RptItemBase p_parent) { _parent = p_parent; Item = new RptText(this); SubTotals = new List <RptMtxSubtotal>(); // 是否在层次前面 _data.AddCell("beforelevel", "1"); // 所占行数/列数 _data.AddCell("span", 1); }
/// <summary> /// 克隆标题 /// </summary> /// <param name="p_parent"></param> /// <returns></returns> public RptMtxSubtitle Clone(RptItemBase p_parent) { RptMtxSubtitle title = new RptMtxSubtitle(p_parent); title.Data.Copy(this.Data); title.Item.Data.Copy(Item.Data); foreach (RptMtxSubtitle sub in SubTitles) { title.SubTitles.Add(sub.Clone(title)); } return(title); }
/// <summary> /// 克隆小计 /// </summary> /// <param name="p_parent"></param> /// <returns></returns> public RptMtxSubtotal Clone(RptItemBase p_parent) { RptMtxSubtotal total = new RptMtxSubtotal(p_parent); total.Data.Copy(this.Data); total.Item.Data.Copy(Item.Data); foreach (RptMtxSubtotal sub in SubTotals) { total.SubTotals.Add(sub.Clone(total)); } return(total); }
/// <summary> /// 触发报表项属性值变化事件 /// </summary> /// <param name="p_item"></param> /// <param name="p_cell"></param> public void OnItemValueChanged(RptItemBase p_item, Cell p_cell) { ValueChangedCmd cmd = RptCmds.ValueChanged; if (!cmd.IsSetting) { ItemValueChanged?.Invoke(p_cell, p_cell); if (p_item is RptText pt && TextChanged != null) { TextChanged(pt, p_cell); } p_cell.AcceptChanges(); } }
/// <summary> /// 创建小计 /// </summary> /// <param name="totals"></param> /// <param name="p_header"></param> /// <param name="p_matInst"></param> /// <param name="p_curRow"></param> /// <param name="p_data"></param> /// <param name="p_loc"></param> void CreateTotalInst(List <RptMtxSubtotal> totals, RptMtxHeader p_header, RptMatrixInst p_matInst, Row p_curRow, RptData p_data, TotalLocation p_loc) { foreach (RptMtxSubtotal total in totals) { if (total.TotalLoc == p_loc) { if (total.SubTotals.Count > 0) { CreateTotalInst(total.SubTotals, p_header, p_matInst, p_curRow, p_data, p_loc); } else { RptMtxHeaderInst totalInst = new RptMtxHeaderInst(p_header); for (int j = 0; j < p_header.Levels.IndexOf(total.Level); j++) { RptMtxLevel nLevel = p_header.Levels[j]; nLevel.Item.ColSpan = 1; nLevel.Item.RowSpan = 1; RptTextInst txtlevel = new RptTextInst(nLevel.Item); totalInst.TxtInsts.Add(txtlevel); totalInst.Filter.Add(nLevel.Field, p_curRow.Str(nLevel.Field)); } RptItemBase parent = total.Parent; while (parent is RptMtxSubtotal) { RptTextInst parTotal = new RptTextInst((parent as RptMtxSubtotal).Item); totalInst.TxtInsts.Add(parTotal); parent = parent.Parent; } RptTextInst txtTotal = new RptTextInst(total.Item); totalInst.TxtInsts.Add(txtTotal); totalInst.RptData = p_data; totalInst.RptData.Current = p_curRow.Index; totalInst.Index = p_curRow.Index; if (p_header is RptMtxColHeader) { totalInst.MtxRowsCol = total.Col; p_matInst.AddColHeader(totalInst); } else { totalInst.MtxRowsRow = total.Row; p_matInst.AddRowHeader(totalInst); } } } } }
/// <summary> /// 创建标题 /// </summary> /// <param name="p_titles"></param> /// <param name="p_header"></param> /// <param name="p_matInst"></param> /// <param name="p_curRow"></param> /// <param name="p_data"></param> void CreateSubTiltelInst(List <RptMtxSubtitle> p_titles, RptMtxHeader p_header, RptMatrixInst p_matInst, Row p_curRow, RptData p_data) { foreach (RptMtxSubtitle title in p_titles) { if (title.SubTitles.Count > 0) { CreateSubTiltelInst(title.SubTitles, p_header, p_matInst, p_curRow, p_data); } else { RptMtxHeaderInst titleInst = new RptMtxHeaderInst(p_header); for (int j = 0; j <= p_header.Levels.IndexOf(title.Level); j++) { RptMtxLevel nLevel = p_header.Levels[j]; nLevel.Item.ColSpan = 1; nLevel.Item.RowSpan = 1; RptTextInst txtlevel = new RptTextInst(nLevel.Item); titleInst.TxtInsts.Add(txtlevel); titleInst.Filter.Add(nLevel.Field, p_curRow.Str(nLevel.Field)); } RptItemBase parent = title.Parent; while (parent is RptMtxSubtotal) { RptTextInst parTotal = new RptTextInst((parent as RptMtxSubtotal).Item); titleInst.TxtInsts.Add(parTotal); parent = parent.Parent; } RptTextInst txtTotal = new RptTextInst(title.Item); titleInst.TxtInsts.Add(txtTotal); titleInst.RptData = p_data; titleInst.RptData.Current = p_curRow.Index; titleInst.Index = p_curRow.Index; if (p_header is RptMtxColHeader) { titleInst.MtxRowsCol = title.Col; p_matInst.AddColHeader(titleInst); } else { titleInst.MtxRowsRow = title.Row; p_matInst.AddRowHeader(titleInst); } } } }
/// <summary> /// 按照位置整理出每个报表项的左上位置列表 /// 两报表项之间位置关系有三种: /// 1. 无影响 /// 2. 垂直依赖 /// 3. 水平依赖 /// </summary> void SortItems() { RptItemBase item; RptItemInst itemInst; List <RptItemInst> topList = new List <RptItemInst>(); List <RptItemInst> leftList = new List <RptItemInst>(); for (int i = 0; i < _children.Count; i++) { item = _children[i].Item; itemInst = _children[i]; topList.Clear(); leftList.Clear(); // 查找所有上侧左侧的报表项 for (int j = 0; j < _children.Count; j++) { RptItemBase tgt = _children[j].Item; RptItemInst tgtInst = _children[j]; Type tp = tgtInst.GetType(); if ((tgt.Row + tgt.RowSpan - 1) < item.Row && item.IsCrossWithColumns(tgt.Col, tgt.ColSpan)) { topList.Add(tgtInst); } else if ((tgt.Col + tgt.ColSpan - 1) < item.Col && item.IsCrossWithRows(tgt.Row, tgt.RowSpan)) { leftList.Add(tgtInst); } } if (topList.Count > 0) { itemInst.TopItems = GetTopLeftItems(topList, true); } if (leftList.Count > 0) { itemInst.LeftItems = GetTopLeftItems(leftList, false); } } }
/// <summary> /// 是否需要垂直分页 /// </summary> /// <param name="p_item"></param> /// <returns></returns> public bool TestPageBreak(RptItemInst p_item) { RptRegion region = p_item.Region; PageDefine rowPage = Rows[Rows.Count - 1]; int lastRow = rowPage.Start + rowPage.Count; int deltaRow = region.Row + region.RowSpan - lastRow; RptItemBase item = p_item.Item; double topHeight = 0; if (deltaRow > 0) { topHeight = rowPage.Size.Sum(); } else { for (int i = 0; i < region.Row - rowPage.Start; i++) { topHeight += rowPage.Size[i]; } } return(topHeight + item.Height > BodyHeight - TblFooterHeight); }
public override void Undo(object p_args) { SubTitleCmdArgs args = (SubTitleCmdArgs)p_args; RptMtxSubtitle title = args.SubTitle; RptItemBase parent = args.Parent; RptMatrix mtx = null; if (parent is RptMtxLevel) { RptMtxLevel pLevel = parent as RptMtxLevel; mtx = pLevel.Matrix; args.BackMtxRow(); pLevel.SubTitles.Insert(args.TilteIndex, title); } else { RptMtxSubtitle pTotal = parent as RptMtxSubtitle; mtx = pTotal.Level.Matrix; args.BackMtxRow(); pTotal.SubTitles.Insert(args.TilteIndex, title); } mtx.Update(true); }
public override void Undo(object p_args) { SubTitleCmdArgs args = (SubTitleCmdArgs)p_args; RptMtxSubtitle title = args.SubTitle; RptItemBase parent = args.Parent; RptMatrix mtx = null; if (parent is RptMtxLevel) { RptMtxLevel pLevel = parent as RptMtxLevel; mtx = pLevel.Matrix; args.DelMtxRows(); pLevel.SubTitles.Remove(title); } else { RptMtxSubtitle pTitle = parent as RptMtxSubtitle; mtx = pTitle.Level.Matrix; args.DelMtxRows(); pTitle.SubTitles.Remove(title); } mtx.Update(true); }
public override void Undo(object p_args) { SubTotalCmdArgs args = (SubTotalCmdArgs)p_args; RptMtxSubtotal total = args.SubTotal; RptItemBase parent = args.Parent; RptMatrix mtx = null; if (parent is RptMtxLevel) { RptMtxLevel pLevel = parent as RptMtxLevel; mtx = pLevel.Matrix; args.DelMtxRows(); pLevel.SubTotals.Remove(total); } else { RptMtxSubtotal pTotal = parent as RptMtxSubtotal; mtx = pTotal.Level.Matrix; args.DelMtxRows(); pTotal.SubTotals.Remove(total); } mtx.Update(true); }
public override object Execute(object p_args) { SubTitleCmdArgs args = (SubTitleCmdArgs)p_args; RptItemBase parent = args.Parent; RptMtxSubtitle title = args.SubTitle; RptMtxHeaderType headerType = RptMtxHeaderType.Col; RptMatrix mtx = null; args.InitData(); if (parent is RptMtxLevel) { RptMtxLevel pLevel = parent as RptMtxLevel; mtx = pLevel.Matrix; if (pLevel.Parent is RptMtxRowHeader) { headerType = RptMtxHeaderType.Row; } DelRows(args, headerType, mtx, title); args.TilteIndex = pLevel.SubTitles.IndexOf(title); pLevel.SubTitles.Remove(title); } else { RptMtxSubtitle pTotal = parent as RptMtxSubtitle; mtx = pTotal.Level.Matrix; if (pTotal.Level.Parent is RptMtxRowHeader) { headerType = RptMtxHeaderType.Row; } DelRows(args, headerType, mtx, title); args.TilteIndex = pTotal.SubTitles.IndexOf(title); pTotal.SubTitles.Remove(title); } mtx.Update(true); return(null); }
public override object Execute(object p_args) { SubTitleCmdArgs args = (SubTitleCmdArgs)p_args; RptItemBase parent = args.Parent; RptMtxHeaderType headerType = RptMtxHeaderType.Col; RptMtxSubtitle title = args.SubTitle; RptMatrix mtx = null; if (title == null) { title = new RptMtxSubtitle(parent); args.InitData(); if (parent is RptMtxLevel) { RptMtxLevel pLevel = parent as RptMtxLevel; mtx = pLevel.Matrix; if (pLevel.Parent is RptMtxRowHeader) { headerType = RptMtxHeaderType.Row; } title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle()); RptMtxHeader header = pLevel.Parent as RptMtxHeader; if (pLevel.SubTitles.Count > 0 || header.Levels.Count > header.Levels.IndexOf(pLevel) + 1) { int curIndex = 0; if (headerType == RptMtxHeaderType.Row) { int subLevelSpan = 0; if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1) { subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].RowSpan; } curIndex = pLevel.Row - mtx.ColHeader.Row - mtx.ColHeader.RowSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles); args.OpsRows.Add(InsertNewRow(mtx, curIndex)); } else { int subLevelSpan = 0; if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1) { subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].ColSpan; } curIndex = pLevel.Col - mtx.RowHeader.Col - mtx.RowHeader.ColSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles); foreach (RptMtxRow row in mtx.Rows) { args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList()); } } args.CurIndex = curIndex; } pLevel.SubTitles.Add(title); } else { RptMtxSubtitle pTitle = parent as RptMtxSubtitle; mtx = pTitle.Level.Matrix; if (pTitle.Level.Parent is RptMtxRowHeader) { headerType = RptMtxHeaderType.Row; } title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle()); if (pTitle.SubTitles.Count > 0) { int curIndex = 0; if (headerType == RptMtxHeaderType.Row) { curIndex = pTitle.Row + pTitle.RowSpan - mtx.ColHeader.Row - mtx.ColHeader.RowSpan; args.OpsRows.Add(InsertNewRow(mtx, curIndex)); } else { curIndex = pTitle.Col + pTitle.ColSpan - mtx.RowHeader.Col - mtx.RowHeader.ColSpan; foreach (RptMtxRow row in mtx.Rows) { args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList()); } } args.CurIndex = curIndex; } pTitle.SubTitles.Add(title); } args.SubTitle = title; } else { mtx = title.Level.Matrix; if (parent is RptMtxLevel) { args.BackMtxRow(); (parent as RptMtxLevel).SubTitles.Add(title); } else { (parent as RptMtxSubtitle).SubTitles.Add(title); } } mtx.Update(true); return(title); }
public RptTableInst(RptItemBase p_item) : base(p_item) { _rows = new List <RptTblPartInst>(); }
/// <summary> /// 输出单列布局 /// </summary> void OutputList() { RptItemBase tempItem; RptRootInst root = Inst; List <RptRegion> regions = new List <RptRegion>(); RptRegion region = new RptRegion(_region.Row, _region.Col, 0, _item.ColSpan); regions.Add(region); if (_header != null) { _header.Output(); region.RowSpan += _header.Region.RowSpan; } RptTable tbl = _item as RptTable; int rowCount = tbl.RowBreakCount; int colCount = tbl.ColBreakCount; int rowNum = 0; foreach (RptTblPartInst tabInst in _rows) { RptItemBase item = tabInst.Item; tabInst.Region = new RptRegion( region.Row + region.RowSpan, region.Col, item.RowSpan, item.ColSpan); bool rowBreak = false; bool colBreak = false; if (rowCount == -1) { // 自动计算重复行数 if (root.TestPageBreak(tabInst)) { // 需要换页 if (colCount != 0 && (regions.Count % colCount) == 0) { rowBreak = true; colBreak = true; } else { rowBreak = false; colBreak = true; } } } else if (rowNum == rowCount) { // 应该换列 if (colCount != 0 && (regions.Count % colCount) == 0) { rowBreak = true; colBreak = true; } else { rowBreak = false; colBreak = true; } } if (colBreak) { // 换新列,重新累计行数 rowNum = 0; if (rowBreak) { // 列数达到后换行显示 RptRegion region2 = regions[regions.Count - colCount]; region = new RptRegion( region2.Row + region2.RowSpan, region2.Col, 0, region2.ColSpan); regions.Add(region); } else { RptRegion region3 = regions[regions.Count - 1]; region = new RptRegion( region3.Row, region3.Col + region3.ColSpan, 0, region3.ColSpan); regions.Add(region); } // 输出表头 if (_header != null) { RptTblHeaderInst header = _header.Clone() as RptTblHeaderInst; header.Region = region.Clone() as RptRegion; header.Region.RowSpan = header.Item.RowSpan; header.Output(); region.RowSpan = (header.Region.Row + header.Region.RowSpan) - region.Row; } tempItem = tabInst.Item; tabInst.Region = new RptRegion( region.Row + region.RowSpan, region.Col, tempItem.RowSpan, tempItem.ColSpan); tabInst.Output(); } else { tabInst.Output(); } region.RowSpan = (tabInst.Region.Row + tabInst.Region.RowSpan) - region.Row; if (((tabInst.Region.Row + tabInst.Region.RowSpan) - _region.Row) > _region.RowSpan) { _region.RowSpan = (tabInst.Region.Row + tabInst.Region.RowSpan) - _region.Row; } if (((tabInst.Region.Col + tabInst.Region.ColSpan) - _region.Col) > _region.ColSpan) { _region.ColSpan = (tabInst.Region.Col + tabInst.Region.ColSpan) - _region.Col; } rowNum++; } if (_footer != null) { region = _region; if (regions.Count > 0) { region = regions[regions.Count - 1]; } tempItem = _footer.Item; _footer.Region = new RptRegion( region.Row + region.RowSpan, region.Col, tempItem.RowSpan, tempItem.ColSpan); _footer.Output(); if (((_footer.Region.Row + _footer.Region.RowSpan) - _region.Row) > _region.RowSpan) { _region.RowSpan = (_footer.Region.Row + _footer.Region.RowSpan) - _region.Row; } if (((_footer.Region.Col + _footer.Region.ColSpan) - _region.Col) > _region.ColSpan) { _region.ColSpan = (_footer.Region.Col + _footer.Region.ColSpan) - _region.Col; } } }
public RptText(RptItemBase p_parent) : this(p_parent.Part) { _parent = p_parent; }
public RptTblGroupFooterInst(RptItemBase p_item) : base(p_item) { }
public RptTextInst(RptItemBase p_item) : base(p_item) { }
public RptItemInst(RptItemBase p_item) { _item = p_item; Visible = true; }
public RptOutputInst(RptItemBase p_item) : base(p_item) { }
public override object Execute(object p_args) { SubTotalCmdArgs args = (SubTotalCmdArgs)p_args; RptItemBase parent = args.Parent; RptMtxHeaderType headerType = RptMtxHeaderType.Col; RptMtxSubtotal total = args.SubTotal; RptMatrix mtx = null; if (total == null) { total = new RptMtxSubtotal(parent); args.InitData(); if (parent is RptMtxLevel) { RptMtxLevel pLevel = parent as RptMtxLevel; mtx = pLevel.Matrix; if (pLevel.Parent is RptMtxRowHeader) { headerType = RptMtxHeaderType.Row; } total.Item.Val = string.Format("subtotal{0}", mtx.GetMaxTotal()); int curIndex = 0; if (headerType == RptMtxHeaderType.Row) { curIndex = pLevel.Row; if (!mtx.HideRowHeader && !mtx.HideColHeader) { curIndex -= (mtx.Corner.Row + mtx.Corner.RowSpan); } args.OpsRows.Add(InsertNewRow(mtx, curIndex)); } else { curIndex = pLevel.Col - mtx.Rows[0].Col; foreach (RptMtxRow row in mtx.Rows) { args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList()); } } args.CurIndex = curIndex; } else { RptMtxSubtotal pTotal = parent as RptMtxSubtotal; mtx = pTotal.Level.Matrix; if (pTotal.Level.Parent is RptMtxRowHeader) { headerType = RptMtxHeaderType.Row; } total.Item.Val = string.Format("subtotal{0}", mtx.GetMaxTotal()); if (pTotal.SubTotals.Count > 0) { int curIndex = 0; if (headerType == RptMtxHeaderType.Row) { curIndex = pTotal.Row + pTotal.GetCount(); if (!mtx.HideColHeader && !mtx.HideRowHeader) { curIndex -= (mtx.Corner.Row + mtx.Corner.RowSpan); } args.OpsRows.Add(InsertNewRow(mtx, curIndex)); } else { curIndex = pTotal.Col - mtx.Rows[0].Col + pTotal.GetCount(); foreach (RptMtxRow row in mtx.Rows) { args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList()); } } args.CurIndex = curIndex; } } } else { mtx = total.Level.Matrix; args.BackMtxRow(); } if (parent is RptMtxLevel) { (parent as RptMtxLevel).SubTotals.Add(total); } else { (parent as RptMtxSubtotal).SubTotals.Add(total); } args.SubTotal = total; mtx.Update(true); return(total); }
public RptTblGroupHeaderInst(RptItemBase p_item) : base(p_item) { }
/// <summary> /// 补充报表项及左上的行列定义,处理分页 /// </summary> /// <param name="p_item"></param> void PrepareItem(RptItemInst p_item) { RptRegion region = p_item.Region; RptItemBase item = p_item.Item; PageDefine rowPage = Rows[Rows.Count - 1]; PageDefine colPage = Cols[Cols.Count - 1]; int lastRow = rowPage.Start + rowPage.Count; int lastCol = colPage.Start + colPage.Count; int deltaRow = region.Row + region.RowSpan - lastRow; int deltaCol = region.Col + region.ColSpan - lastCol; //已经垂直分页 if (region.Row < rowPage.Start && region.Row + region.RowSpan > rowPage.Start) { deltaRow = region.RowSpan - rowPage.Count; region.Row = rowPage.Start; } //已经水平分页 if (region.Col < colPage.Start && region.Col + region.ColSpan > colPage.Start) { deltaCol = region.ColSpan - colPage.Count; region.Col = colPage.Start; } // 无需补充 if (deltaRow <= 0 && deltaCol <= 0) { return; } // 补充行定义 if (deltaRow > 0) { // 页面已有的总高 double topHeight = rowPage.Size.Sum(); int blankRow = deltaRow - region.RowSpan; double heights = 0; if (blankRow < 0) { for (int i = 0; i < deltaRow; i++) { heights += item.Part.GetRowHeight(item.Row + item.RowSpan - deltaRow + i); } //需要分页 if (!_pageEnding && topHeight + heights > (BodyHeight - TblFooterHeight) && region.Row != rowPage.Start) { VerPageBreak(ref rowPage, ref topHeight); //从元素的起始位置开始分页 for (int j = 0; j < region.RowSpan; j++) { double height = item.Part.GetRowHeight(item.Row + j); rowPage.Size.Add(height); topHeight += height; } } else { //不需要分页 for (int i = 0; i < deltaRow; i++) { double height = item.Part.GetRowHeight(item.Row + item.RowSpan - deltaRow + i); if (topHeight + height > (BodyHeight - TblFooterHeight))//元素高度大于页面高度,截断 { height = (BodyHeight - TblFooterHeight - topHeight) < 0 ? 0 : BodyHeight - TblFooterHeight - topHeight; } rowPage.Size.Add(height); topHeight += height; } } } else { for (int i = 0; i < deltaRow; i++) { double height = item.Part.GetRowHeight(item.Row + item.RowSpan - deltaRow + i); if (i == blankRow) { for (int j = i; j < deltaRow; j++) { heights += item.Part.GetRowHeight(item.Row + item.RowSpan - deltaRow + j); } } // 在报表项上 bool inItem = lastRow + i >= region.Row; if (height > BodyHeight - TblFooterHeight) { height = BodyHeight - TblFooterHeight; } if (i == blankRow && heights > BodyHeight - TblFooterHeight) { heights = BodyHeight - TblFooterHeight; } // 需要垂直分页 bool verBreak = (i == blankRow) ? (topHeight + heights > BodyHeight - TblFooterHeight) : (topHeight + height > BodyHeight - TblFooterHeight); if (!_pageEnding && verBreak) { VerPageBreak(ref rowPage, ref topHeight, inItem); } rowPage.Size.Add(height); topHeight += height; } } // 重新计算行位置 region.Row = rowPage.Start + rowPage.Count - region.RowSpan; } //补充列定义 if (deltaCol > 0) { // 页面已有的宽度 double leftWidth = colPage.Size.Sum(); int blankCol = deltaCol - region.ColSpan; double widths = 0; //不需要补充空行 if (blankCol < 0) { for (int i = 0; i < deltaCol; i++) { widths += Info.Root.Cols[item.Col + item.ColSpan - deltaCol + i]; } //需要分页 if (!_pageEnding && leftWidth + widths > BodyWidth && region.Col != colPage.Start) { HorPageBreak(ref colPage, ref leftWidth); //从元素的起始位置开始分页 for (int j = 0; j < region.ColSpan; j++) { double width = Info.Root.Cols[item.Col + j]; colPage.Size.Add(width); leftWidth += width; } } else { //不需要分页 for (int i = 0; i < deltaCol; i++) { double width = Info.Root.Cols[item.Col + item.ColSpan - deltaCol + i]; if (leftWidth + width > BodyWidth)//元素宽度大于页面宽度,截断 { width = (BodyWidth - leftWidth) < 0 ? 0 : BodyWidth - leftWidth; } colPage.Size.Add(width); leftWidth += width; } } } else { //需要空行补充 for (int i = 0; i < deltaCol; i++) { double width = Info.Root.Cols[item.Col + item.ColSpan - deltaCol + i]; if (i == blankCol) { for (int j = i; j < deltaCol; j++) { widths += Info.Root.Cols[item.Col + item.ColSpan - deltaCol + j]; } } // 在报表项上 bool inItem = lastCol + i >= region.Col; // 需要水平分页 bool horBreak = (i == blankCol) ? (leftWidth + widths > BodyWidth) : (leftWidth + width > BodyWidth); if (!_pageEnding && horBreak) { HorPageBreak(ref colPage, ref leftWidth, inItem); } colPage.Size.Add(width); leftWidth += width; } } // 重新计算列位置 region.Col = colPage.Start + colPage.Count - region.ColSpan; } }