/// <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> public override Task Build() { RptRootInst inst = Root.Inst; RptTblHeaderInst header = new RptTblHeaderInst(this); if (inst.CurrentTable != null) { inst.CurrentTable.Header = header; } inst.CurrentParent = header; return(BuildChild()); }
/// <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; } } }