/// <summary> /// 获取指定区域所属的页面 /// </summary> /// <param name="p_region"></param> /// <returns></returns> public RptPage GetPage(RptRegion p_region) { int pageX = GetPageIndex(Cols, p_region.Col); int pageY = GetPageIndex(Rows, p_region.Row); return(GetPage(pageX, pageY)); }
/// <summary> /// 切换页面时在新页重复表头 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnPageBegin(object sender, RptPage e) { if (_header != null && (_item as RptTable).RepeatHeader) { int index = _data.Current; RptTblHeaderInst inst = _header.Clone() as RptTblHeaderInst; RptRegion region = new RptRegion( e.Rows.Start, _region.Col, inst.Item.RowSpan, inst.Item.ColSpan); inst.Region = region; double height = _item.Part.GetRowHeight(region.Row + region.RowSpan - e.Rows.Start); if (e.Rows.Size.Count > 0 && height != e.Rows.Size[0]) { e.Rows.Size[0] = height; } inst.Output(); _data.Current = index; // 顺次下移 if (_curPart != null) { _curPart.Region.Row = region.Row + region.RowSpan; } } }
/// <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; }
/// <summary> /// 切换页面时在旧页重复表尾 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnPageEnd(object sender, PageDefine e) { if (_footer != null && (_item as RptTable).RepeatFooter) { int index = _data.Current; RptTblFooterInst inst = _footer.Clone() as RptTblFooterInst; RptRegion region = new RptRegion( e.Start + e.Count, _region.Col, inst.Item.RowSpan, inst.Item.ColSpan); inst.Region = region; inst.Output(); _data.Current = index; // 顺次下移 if (_curPart != null) { _curPart.Region.Row = region.Row + region.RowSpan; } } }
/// <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); }
/// <summary> /// 切换页面时在新页重复行头 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnHorPageBegin(object sender, RptPage e) { RptMatrix matrix = base._item as RptMatrix; if (!matrix.HideRowHeader && matrix.RepeatRowHeader) { _isHasHorBreak = true; RptRootInst root = sender as RptRootInst; //不存在定义,取第一页定义添加到当前页定义 //添加的定义应该以矩阵开始行(列)为开始位置 if (!e.IsColHasDefine()) { e.Cols.Size.InsertRange(0, root.Cols[0].Size.GetRange(matrix.Col, matrix.RowHeader.ColSpan)); } else if (!e.IsRowHasDefine()) { e.Rows.Size.InsertRange(0, root.Rows[0].Size.GetRange(matrix.Row, matrix.ColHeader.RowSpan)); } int span = matrix.RowHeader.ColSpan; int start = e.Cols.Start; //外层列号变更 if (_outPutPart == MtxOutPutPart.Cells) { _regCells.Col = start + span; } else { _regColHeader.Col = start + span; } //再次递归调用时确保数据完整 //行头Region RptRegion headerClone = _regRowHeader.Clone(); //数据源记录索引 int index = RptData.Current; //外部输出的行头索引 int rowIndex = _rowIndex; //外部正在输出的部分 RptMtxHeaderInst curPart = _rowPart; if (!matrix.HideColHeader && !matrix.HideRowHeader) { RptTextInst newCorner = CornerInst.Clone(); newCorner.Region = new RptRegion(_regRowHeader.Row - matrix.ColHeader.RowSpan, start, matrix.ColHeader.RowSpan, matrix.RowHeader.ColSpan); newCorner.Output(); } //从已输出的索引处开始输出 for (int i = rowIndex; i < RowHeaderInsts.Count; i++) { RptMtxHeaderInst instClone = RowHeaderInsts[i].Clone(); _rowPart = instClone; instClone.Region = new RptRegion(_regRowHeader.Row, start, instClone.Item.RowSpan, instClone.Item.ColSpan); //输出过程中可能触发分页事件,提前计算新行位置,输出后还原 _regRowHeader.Row += matrix.ColHeader.RowSpan; instClone.Output(); _regRowHeader.Row -= matrix.ColHeader.RowSpan; _regRowHeader.Row += 1; //下次输出位置已经输出过,不再输出 if (_rowUsed.Contains(_regRowHeader.Row) && _colUsed.Contains(start)) { break; } _rowIndex++; } _rowPart = curPart; _rowIndex = rowIndex; RptData.Current = index; _regRowHeader = headerClone.Clone(); //后移 span 个格 if (_outPutPart == MtxOutPutPart.Cells) { _cellPart.Region.Col = start + span; } else { _colPart.TxtInsts[0].Region.Col = start + span; } //将占用列加入到列表 for (int i = 0; i < span; i++) { if (!_colUsed.Contains(start + i)) { _colUsed.Add(start + i); } } } }
/// <summary> /// 切换页面时在新页重复列头 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnVerPageBegin(object sender, RptPage e) { RptMatrix matrix = base._item as RptMatrix; if (!matrix.HideColHeader && matrix.RepeatColHeader) { RptRootInst root = sender as RptRootInst; //当不存在水平分页时,加入列头的定义 if (!_isHasHorBreak) { e.Rows.Size.InsertRange(0, root.Rows[0].Size.GetRange(matrix.Row, matrix.ColHeader.RowSpan)); } int span = matrix.ColHeader.RowSpan; int start = e.Rows.Start; //外层列号变更 if (_outPutPart == MtxOutPutPart.Cells) { _regCells.Row = start + span; } else { _regRowHeader.Row = start + span; } //再次递归调用时确保数据完整 //行头Region RptRegion headerClone = _regColHeader.Clone(); //数据源记录索引 int index = RptData.Current; //外部输出的列头索引 int colIndex = _colIndex; //外部正在输出的部分 RptMtxHeaderInst curPart = _colPart; if (!matrix.HideColHeader && !matrix.HideRowHeader) { RptTextInst newCorner = CornerInst.Clone(); newCorner.Region = new RptRegion(start, _regColHeader.Col - matrix.RowHeader.ColSpan, matrix.ColHeader.RowSpan, matrix.RowHeader.ColSpan); newCorner.Output(); } for (int i = _colIndex; i < ColHeaderInsts.Count; i++) { RptMtxHeaderInst instClone = ColHeaderInsts[i].Clone(); _colPart = instClone; instClone.Region = new RptRegion(start, _regColHeader.Col, instClone.Item.RowSpan, instClone.Item.ColSpan); //输出过程中可能触发分页事件,提前计算新列位置,输出后还原 _regColHeader.Col += matrix.RowHeader.ColSpan; instClone.Output(); _regColHeader.Col -= matrix.RowHeader.ColSpan; _regColHeader.Col += 1; //下次输出位置已经输出过,不再输出 if (_colUsed.Contains(_regColHeader.Col) && _rowUsed.Contains(start)) { break; } _colIndex++; } _colPart = curPart; _colIndex = colIndex; RptData.Current = index; _regColHeader = headerClone.Clone(); //后移 span 个格 if (_outPutPart == MtxOutPutPart.Cells) { _cellPart.Region.Row = start + span; } else { _rowPart.TxtInsts[0].Region.Row = start + span; } //将占用行加入到列表 for (int i = 0; i < span; i++) { if (!_rowUsed.Contains(start + i)) { _rowUsed.Add(start + i); } } } }
protected override void DoOutput() { RptRootInst root = Inst; RptMatrix matrix = base._item as RptMatrix; RptRegion regClone = _region.Clone(); _region.RowSpan = 0; _region.ColSpan = 0; //矩阵角 if (!matrix.HideColHeader && !matrix.HideRowHeader) { CornerInst.Region = new RptRegion(_region.Row, _region.Col, matrix.ColHeader.RowSpan, matrix.RowHeader.ColSpan); CornerInst.Output(); _region.RowSpan += matrix.Corner.RowSpan; _region.ColSpan += matrix.Corner.ColSpan; } root.HorPageBegin += OnHorPageBegin; root.VerPageBegin += OnVerPageBegin; _rowIndex = _colIndex = 0; //列头 //可能出现水平分页、垂直分页相互调用,所以行、列Region都定义 _regColHeader = regClone.Clone(); _regRowHeader = regClone.Clone(); if (!matrix.HideRowHeader) { _regColHeader.Col += matrix.RowHeader.ColSpan; } if (!matrix.HideColHeader) { _outPutPart = MtxOutPutPart.ColHeader; _regRowHeader.Row += matrix.ColHeader.RowSpan; foreach (RptMtxHeaderInst inst in ColHeaderInsts) { _colPart = inst; inst.Region = new RptRegion(_regColHeader.Row, _regColHeader.Col, inst.Item.RowSpan, inst.Item.ColSpan); inst.Output(); _regColHeader.Col += 1; _colIndex++; _region.ColSpan++; } } //行头 //可能出现水平分页、垂直分页相互调用,所以行、列Region都定义 _colIndex = 0; _regColHeader = regClone.Clone(); _regRowHeader = regClone.Clone(); if (!matrix.HideColHeader) { _regRowHeader.Row += matrix.ColHeader.RowSpan; } if (!matrix.HideRowHeader) { _outPutPart = MtxOutPutPart.RowHeader; _regColHeader.Col += matrix.RowHeader.ColSpan; foreach (RptMtxHeaderInst inst in RowHeaderInsts) { _rowPart = inst; inst.Region = new RptRegion(_regRowHeader.Row, _regRowHeader.Col, inst.Item.RowSpan, inst.Item.ColSpan); inst.Output(); _regRowHeader.Row += 1; _rowIndex++; _region.RowSpan++; } } //数据 //还原行头、列头为开始状态(用于分页) _rowIndex = _colIndex = 0; _regColHeader = regClone.Clone(); _regRowHeader = regClone.Clone(); _regCells = regClone.Clone(); if (!matrix.HideRowHeader) { _regColHeader.Col += matrix.RowHeader.ColSpan; _regCells.Col += matrix.RowHeader.ColSpan; } if (!matrix.HideColHeader) { _regRowHeader.Row += matrix.ColHeader.RowSpan; _regCells.Row += matrix.ColHeader.RowSpan; } int colindex = 0; int col = _regCells.Col; _outPutPart = MtxOutPutPart.Cells; foreach (RptTextInst inst in _cellInsts) { _cellPart = inst; RptData.Current = GetCurrent(inst.Filter); //换行 if (colindex == ColHeaderInsts.Count) { _regCells.Row += 1; //当前行被占用,下移 while (_rowUsed.Contains(_regCells.Row)) { _regCells.Row++; } _regCells.Col = col; colindex = 0; } if (colindex != 0) { _regCells.Col++; //当前列被占用,下移 while (_colUsed.Contains(_regCells.Col)) { _regCells.Col++; } } inst.Region = new RptRegion(_regCells.Row, _regCells.Col, inst.Item.RowSpan, inst.Item.ColSpan); inst.Output(); colindex++; } root.HorPageBegin -= OnHorPageBegin; root.VerPageBegin -= OnVerPageBegin; }
/// <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; } } }
/// <summary> /// 计算元素的位置信息 /// </summary> void RefreshPosition() { if (_region != null) { return; } _region = new RptRegion(); // 垂直位置 if (_topItems != null && _topItems.Count > 0) { // 上部存在元素 foreach (var inst in _topItems) { if (!inst.Outputted) { inst.Output(); } } // 最靠近的上部元素 var lastTop = _topItems[0]; if (_topItems.Count > 1) { for (int i = 1; i < _topItems.Count; i++) { var inst = _topItems[i]; if (inst.Region.Row + inst.Region.RowSpan > lastTop.Region.Row + lastTop.Region.RowSpan) { lastTop = inst; } } } // 模板设计时与上部元素的行距 int num = _item.Row - (lastTop.Item.Row + lastTop.Item.RowSpan); _region.Row = (lastTop.Region.Row + lastTop.Region.RowSpan) + num; } else if (_parent != null) { // 报表项内部元素 _region.Row = _parent.Region.Row + (_item.Row - _parent.Item.Row); } else { // 报表项 _region.Row = _item.Row; } // 水平位置 if (_leftItems != null && _leftItems.Count != 0) { foreach (var inst in _leftItems) { if (!inst.Outputted) { inst.Output(); } } var lastLeft = _leftItems[0]; if (_leftItems.Count > 1) { for (int i = 1; i < _leftItems.Count; i++) { var inst = _leftItems[i]; if ((inst.Region.Col + inst.Region.ColSpan) > (lastLeft.Region.Col + lastLeft.Region.ColSpan)) { lastLeft = inst; } } } int num3 = _item.Col - (lastLeft.Item.Col + lastLeft.Item.ColSpan); _region.Col = (lastLeft.Region.Col + lastLeft.Region.ColSpan) + num3; } else if (_parent != null) { _region.Col = _parent.Region.Col + (_item.Col - _parent.Item.Col); } else { _region.Col = _item.Col; } _region.RowSpan = _item.RowSpan; _region.ColSpan = _item.ColSpan; }
/// <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; } }
/// <summary> /// 自动行高时重置行高,前提: /// 1. AutoHeight为true /// 2. 只占一行 /// 3. 当前输出位置在页的末尾 /// 4. 测量高度大于原高度 /// </summary> /// <param name="p_item"></param> /// <param name="p_height"></param> public void SyncRowHeight(RptTextInst p_item, double p_height) { PageDefine rows = p_item.Page.Rows; RptRegion region = p_item.Region; // 只支持当前输出位置在页的末尾,非末尾情况效率太低! if (region.Row != rows.Start + rows.Count - 1) { return; } // 无需调整 int index = rows.Count - 1; if (p_height <= rows.Size[index] || _pageEnding) { return; } // 上部高度 double topHeight = 0; for (int i = 0; i < index; i++) { topHeight += rows.Size[i]; } // 当前页能放下 if (topHeight + p_height <= BodyHeight - TblFooterHeight) { rows.Size[index] = p_height; return; } // 需要垂直分页 // 记录同行项 RptPage prePage = p_item.Page; var sameRowItems = (from item in prePage.Items where item.Region.Row == region.Row select item).ToList(); rows.Size.RemoveAt(index); if (VerPageEnd != null) { _pageEnding = true; VerPageEnd(this, rows); _pageEnding = false; } PageDefine next = new PageDefine(); next.Start = rows.Start + rows.Count; Rows.Add(next); // 重新计算行位置 int newIndex = next.Start + next.Count; double validHeight = BodyHeight - TblFooterHeight - next.Size.Sum(); if (p_height > validHeight) { p_height = validHeight; } next.Size.Add(p_height); // 处理同行项 RptPage page = CreatePage(prePage.X, prePage.Y + 1); foreach (var item in sameRowItems) { item.Region.Row = newIndex; prePage.Items.Remove(item); page.AddItem(item); } }