RptTblPartRow CopyTableRow(RptTblPartRow p_source, RptTblPartRow p_dest) { RptText text = null; RptText newTxt = null; for (int i = 0; i < p_source.Cells.Count; i++) { text = p_source.Cells[i]; newTxt = (RptText)text.Clone(); newTxt.SetParentItem(p_dest); p_dest.Cells.Add(newTxt); } return(p_dest); }
/// <summary> /// 加载table的行单元格,不进行样式清除工作 /// </summary> /// <param name="p_tblRow"></param> /// <param name="p_rowIdx"></param> /// <param name="p_colIdx"></param> void LoadTblRow(RptTblPartRow p_tblRow, int p_rowIdx, int p_colIdx) { int colIdx = p_colIdx; Worksheet ws = _owner.Excel.Sheets[0]; for (int i = 0; i < p_tblRow.Cells.Count; i++) { RptText txt = p_tblRow.Cells[i]; txt.Row = p_rowIdx; txt.Col = colIdx++; Dt.Cells.Data.Cell cell = ws[txt.Row, txt.Col]; cell.Value = txt.Data.Str("val"); txt.ApplyStyle(cell); } }
public override object Execute(object p_args) { InsertTblGrpCmdArgs args = (InsertTblGrpCmdArgs)p_args; RptTable table = args.Table; if (table.Groups == null) { table.Groups = new List <RptTblGroup>(); } RptTblPartRow row = new RptTblPartRow(args.Grp.Header); InsertTableCmd.BuildCells(row, table.ColSpan); args.Grp.Header.Rows.Add(row); RptTblPartRow r = new RptTblPartRow(args.Grp.Footer); InsertTableCmd.BuildCells(r, table.ColSpan); args.Grp.Footer.Rows.Add(r); args.Table.Groups.Add(args.Grp); args.Table.CalcRowSpan(); args.Table.Update(false); return(null); }
public override object Execute(object p_args) { InsertCmdArgs args = (InsertCmdArgs)p_args; RptTable tbl = args.RptItem as RptTable; RptPart con = tbl.Part; //通过重做重新加载table,不用处理 if (tbl.Header != null || tbl.Body != null || tbl.Footer != null) { con.Items.Add(tbl); return(tbl); } CellRange range = args.CellRange; tbl.Row = range.Row; tbl.Col = range.Column; tbl.RowSpan = range.RowCount; tbl.ColSpan = range.ColumnCount; RptTblPartRow tblRow; switch (tbl.RowSpan) { case 1: tbl.Body = new RptTblRow(tbl); tblRow = new RptTblPartRow(tbl.Body); tbl.Body.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); break; case 2: tbl.Header = new RptTblHeader(tbl); tblRow = new RptTblPartRow(tbl.Header); tbl.Header.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); tbl.Body = new RptTblRow(tbl); tblRow = new RptTblPartRow(tbl.Body); tbl.Body.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); break; default: tbl.Header = new RptTblHeader(tbl); tblRow = new RptTblPartRow(tbl.Header); tbl.Header.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); tbl.Body = new RptTblRow(tbl); for (int i = 0; i < tbl.RowSpan - 2; i++) { tblRow = new RptTblPartRow(tbl.Body); tbl.Body.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); } tbl.Footer = new RptTblFooter(tbl); tblRow = new RptTblPartRow(tbl.Footer); tbl.Footer.Rows.Add(tblRow); BuildCells(tblRow, tbl.ColSpan); break; } con.Items.Add(tbl); return(tbl); }
void CopyTableStruct(RptTable p_source, RptTable p_dest) { int rowCount = 0; RptTblPartRow tmpRow = null; if (p_source.Header != null && (rowCount = p_source.Header.Rows.Count) > 0) { RptTblHeader header = new RptTblHeader(p_dest); for (int i = 0; i < rowCount; i++) { tmpRow = new RptTblPartRow(header); header.Rows.Add(CopyTableRow(this.Header.Rows[i], tmpRow)); } p_dest.Header = header; } if (p_source.Body != null && (rowCount = p_source.Body.Rows.Count) > 0) { RptTblRow body = new RptTblRow(p_dest); for (int i = 0; i < rowCount; i++) { tmpRow = new RptTblPartRow(body); body.Rows.Add(CopyTableRow(this.Body.Rows[i], tmpRow)); } p_dest.Body = body; } if (p_source.Footer != null && (rowCount = p_source.Footer.Rows.Count) > 0) { RptTblFooter foot = new RptTblFooter(p_dest); for (int i = 0; i < rowCount; i++) { tmpRow = new RptTblPartRow(foot); foot.Rows.Add(CopyTableRow(this.Footer.Rows[i], tmpRow)); } p_dest.Footer = foot; } int grpCount = 0; if (p_source.Groups != null && (grpCount = p_source.Groups.Count) > 0) { RptTblGroup grp = null; RptTblGroupHeader grpHeader = null; RptTblGroupFooter grpFooter = null; RptTblGroup newGrp = null; RptTblGroupHeader newGrpHeader = null; RptTblGroupFooter newGrpFooter = null; if (p_dest.Groups == null) { p_dest.Groups = new List <RptTblGroup>(); } for (int j = 0; j < grpCount; j++) { grp = p_source.Groups[j]; newGrp = new RptTblGroup(p_dest); p_dest.Groups.Add(newGrp); newGrp.Field = grp.Field; if ((grpHeader = grp.Header) != null && (rowCount = grpHeader.Rows.Count) > 0) { newGrpHeader = new RptTblGroupHeader(p_dest); for (int i = 0; i < rowCount; i++) { tmpRow = new RptTblPartRow(newGrpHeader); newGrpHeader.Rows.Add(CopyTableRow(grpHeader.Rows[i], tmpRow)); } newGrp.Header = newGrpHeader; } if ((grpFooter = grp.Footer) != null && (rowCount = grpFooter.Rows.Count) > 0) { newGrpFooter = new RptTblGroupFooter(p_dest); for (int i = 0; i < rowCount; i++) { tmpRow = new RptTblPartRow(grpFooter); newGrpFooter.Rows.Add(CopyTableRow(grpFooter.Rows[i], tmpRow)); } newGrp.Footer = newGrpFooter; } } } }
public DeleTblRowCmdArgs(int p_index, RptTblPartRow p_row) { Index = p_index; Row = p_row; }