using DevExpress.XtraExport.Implementation; using DevExpress.XtraReports.UI; using OTSIncAReportGB; using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; namespace OTSIncAReportApp._1_UI.OTSReportExport { public partial class XtraReport_yb6156 : DevExpress.XtraReports.UI.XtraReport { DataTable _yB6156ABCD; public XtraReport_yb6156(DataTable yB6156ABCD) { InitializeComponent(); _yB6156ABCD=yB6156ABCD; LoadData(); } void LoadData() { if (_yB6156ABCD.Rows.Count < 7) return; for (int i = 0; i < _yB6156ABCD.Rows.Count - 3; i++) { XRTableRow row = xrTable_6156.Rows.LastRow; for (int j = 0; j < _yB6156ABCD.Columns.Count; j++) { row.Cells[j].Text= _yB6156ABCD.Rows[i][j].ToString(); } row.HeightF = 20; xrTable_6156.InsertRowBelow(xrTable_6156.Rows.LastRow); } xrTable_6156.DeleteRow(xrTable_6156.Rows.LastRow); XRTableRow xRTableRow = new XRTableRow(); XRTableCell xRTableCell = new XRTableCell(); xRTableCell.Text = "总计"; xRTableCell.WidthF= xrTable_6156.Rows.LastRow.Cells[0].WidthF; xRTableRow.Cells.Add(xRTableCell); XRTableCell xRTableCell1 = new XRTableCell(); xRTableCell1.Text = "总检测面积:" + _yB6156ABCD.Rows[_yB6156ABCD.Rows.Count-3][1].ToString(); float aa = 0; for (int i = 1; i < 7; i++) { aa += xrTable_6156.Rows.LastRow.Cells[i].WidthF; } xRTableCell1.WidthF = aa; xRTableRow.Cells.Add(xRTableCell1); XRTableCell xRTableCell2 = new XRTableCell(); xRTableCell2.Text = "第二次求和值"; aa = 0; for (int i = 7; i < 14; i++) { aa += xrTable_6156.Rows.LastRow.Cells[i].WidthF; } xRTableCell2.WidthF = aa; xRTableRow.Cells.Add(xRTableCell2); XRTableCell xRTableCell3 = new XRTableCell(); xRTableCell3.Text = _yB6156ABCD.Rows[_yB6156ABCD.Rows.Count-3][14].ToString(); xRTableCell3.WidthF = xrTable_6156.Rows.LastRow.Cells[14].WidthF; xRTableRow.Cells.Add(xRTableCell3); XRTableCell xRTableCell4 = new XRTableCell(); xRTableCell4.Text = _yB6156ABCD.Rows[_yB6156ABCD.Rows.Count - 3][15].ToString(); xRTableCell4.WidthF = xrTable_6156.Rows.LastRow.Cells[15].WidthF; xRTableRow.Cells.Add(xRTableCell4); xrTable_6156.Rows.Add(xRTableRow); xrTable_6156.InsertRowBelow(xrTable_6156.Rows.LastRow); xrTable_6156.Rows.LastRow.Cells[2].Text = "特征值[K(S)和K(O)]"; xrTable_6156.Rows.LastRow.Cells[3].Text = _yB6156ABCD.Rows[_yB6156ABCD.Rows.Count - 2][14].ToString(); xrTable_6156.Rows.LastRow.Cells[4].Text = _yB6156ABCD.Rows[_yB6156ABCD.Rows.Count - 2][15].ToString(); xrTable_6156.InsertRowBelow(xrTable_6156.Rows.LastRow); xrTable_6156.Rows.LastRow.Cells.Remove(xrTable_6156.Rows.LastRow.Cells[4]); xrTable_6156.Rows.LastRow.Cells[0].WidthF = xrTable_6156.Rows[xrTable_6156.Rows.Count-2].Cells[0].WidthF; xrTable_6156.Rows.LastRow.Cells[1].WidthF = xrTable_6156.Rows[xrTable_6156.Rows.Count - 2].Cells[1].WidthF; xrTable_6156.Rows.LastRow.Cells[2].WidthF = xrTable_6156.Rows[xrTable_6156.Rows.Count - 2].Cells[2].WidthF; xrTable_6156.Rows.LastRow.Cells[3].WidthF = xrTable_6156.Rows.LastRow.WidthF- xrTable_6156.Rows.LastRow.Cells[0].WidthF- xrTable_6156.Rows.LastRow.Cells[1].WidthF- xrTable_6156.Rows.LastRow.Cells[2].WidthF; xrTable_6156.Rows.LastRow.Cells[2].Text = "总特征值"; xrTable_6156.Rows.LastRow.Cells[3].Text = _yB6156ABCD.Rows[_yB6156ABCD.Rows.Count - 1][15].ToString(); //xRTableRow = new XRTableRow(); //xRTableCell = new XRTableCell(); //xRTableCell.WidthF = xrTable_6156.Rows.LastRow.Cells[0].Width; //xRTableRow.Cells.Add(xRTableCell); //xRTableCell1 = new XRTableCell(); //xRTableCell1.WidthF = xrTable_6156.Rows.LastRow.Cells[1].Width; //xRTableRow.Cells.Add(xRTableCell1); //xRTableCell2 = new XRTableCell(); //xRTableCell2.Text = "总特征值"; //xRTableCell2.WidthF = xrTable_6156.Rows.LastRow.Cells[2].Width; //xRTableRow.Cells.Add(xRTableCell2); //xRTableCell3 = new XRTableCell(); //xRTableCell3.WidthF = xrTable_6156.Rows.LastRow.Cells[3].WidthF+xrTable_6156.Rows.LastRow.Cells[4].WidthF; //xRTableCell3.Text = _yB6156ABCD.Rows[_yB6156ABCD.Rows.Count - 1][15].ToString(); //xRTableRow.Cells.Add(xRTableCell3); //xrTable_6156.Rows.Add(xRTableRow); AdjustLayout(); } void AdjustLayout() { for (int i = 4; i + 4 < xrTable_6156.Rows.Count; i = i + 4) { xrTable_6156.Rows[i].Cells[0].RowSpan = 4; xrTable_6156.Rows[i].Cells[1].RowSpan = 4; xrTable_6156.Rows[i + 1].Cells[2].RowSpan = 3; xrTable_6156.Rows[i + 1].Cells[14].RowSpan = 3; xrTable_6156.Rows[i + 1].Cells[15].RowSpan = 3; } xrTable_6156.Rows[xrTable_6156.Rows.Count - 3].Cells[0].RowSpan = 3; xrTable_6156.Rows[xrTable_6156.Rows.Count - 3].Cells[1].RowSpan = 3; foreach (XRTableRow row in xrTable_6156.Rows) { foreach (XRTableCell cell in row.Cells) { // 设置文本水平居中和垂直居中 cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; } } } } }