or
public Table DataGrid() { Table table = new Table(); // Get data and bind it to the table System.Data.DataTable data = ChartsData.chartTable(); // Clear table before binding table.ColumnGroups.Clear(); table.Body.Columns.Clear(); table.Body.Rows.Clear(); table.DataSource = data; int colCount = data.Columns.Count; for (int i = 0; i <= colCount - 1; i++) { TableGroup tableGroupColumn = new TableGroup(); table.ColumnGroups.Add(tableGroupColumn); //table.Body.Columns.Add(new TableBodyColumn(Unit.Inch(0.01))); HtmlTextBox txtGroup = new HtmlTextBox() { Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3)), Value = data.Columns[i].ColumnName, Style = { BorderStyle = { Default = BorderType.Solid }, BorderColor = { Default = System.Drawing.Color.Black }, Font = { Name = "Arial", Size = new Unit(10) }, VerticalAlign = VerticalAlign.Middle }, }; tableGroupColumn.ReportItem = txtGroup; HtmlTextBox txtTable = new HtmlTextBox() { Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3)), Value = "=Fields." + data.Columns[i].ColumnName, Style = { BorderStyle = { Default = BorderType.Solid }, BorderColor = { Default = System.Drawing.Color.Black }, BorderWidth = { Default = new Unit(0.5, UnitType.Point) } } }; table.Body.SetCellContent(0, i,txtTable); table.Items.AddRange(new ReportItemBase[] { txtTable, txtGroup }); } return table; }