/// <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); } } } }