private Drawing.TableStyleId GetTableStyleId(bool create) { Drawing.TableProperties tableProperties = GetTableProperties(create); Drawing.TableStyleId result = tableProperties.GetFirstChild <Drawing.TableStyleId>(); if (result == null && create) { result = tableProperties.AppendChild(new Drawing.TableStyleId()); } return(result); }
public void AddContent(ShapeTree shapeTree1, uint ObjectID, PPTXTable Content, Dictionary <string, string> HyperLinkIDMap) { GraphicFrame graphicFrame1 = new GraphicFrame(); AddTableCommonProperty(graphicFrame1, ObjectID); Transform transform1 = SlideWriterHelper.CreateTransform(Content.Transform); A.Graphic graphic1 = new A.Graphic(); A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/table" }; A.Table table1 = new A.Table(); A.TableProperties tableProperties1 = new A.TableProperties() { FirstRow = true, BandRow = true }; A.TableStyleId tableStyleId1 = new A.TableStyleId(); tableStyleId1.Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; tableProperties1.Append(tableStyleId1); table1.Append(tableProperties1); A.TableGrid tableGrid1 = new A.TableGrid(); foreach (var tableColumn in Content.Columns) { tableGrid1.Append(CreateColumn(tableColumn.Width)); } table1.Append(tableGrid1); foreach (var _tableRow in Content.Rows) { table1.Append(CreateRow(Content.Columns, _tableRow, HyperLinkIDMap)); } graphicData1.Append(table1); graphic1.Append(graphicData1); graphicFrame1.Append(transform1); graphicFrame1.Append(graphic1); shapeTree1.Append(graphicFrame1); }
/// <summary> /// Generate Table as below order: /// a:tbl(Table) ->a:tr(TableRow)->a:tc(TableCell) /// We can return TableCell object with CreateTextCell method /// and Append the TableCell object to TableRow /// </summary> /// <returns>Table Object</returns> private static A.Table GenerateTable() { string[,] tableSources = new string[, ] { { "name", "age" }, { "Tom", "25" } }; // Declare and instantiate table A.Table table = new A.Table(); // Specify the required table properties for the table A.TableProperties tableProperties = new A.TableProperties() { FirstRow = true, BandRow = true }; A.TableStyleId tableStyleId = new A.TableStyleId(); tableStyleId.Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; tableProperties.Append(tableStyleId); // Declare and instantiate tablegrid and colums A.TableGrid tableGrid1 = new A.TableGrid(); A.GridColumn gridColumn1 = new A.GridColumn() { Width = 3048000L }; A.GridColumn gridColumn2 = new A.GridColumn() { Width = 3048000L }; tableGrid1.Append(gridColumn1); tableGrid1.Append(gridColumn2); table.Append(tableProperties); table.Append(tableGrid1); for (int row = 0; row < tableSources.GetLength(0); row++) { // Instantiate the table row A.TableRow tableRow = new A.TableRow() { Height = 370840L }; for (int column = 0; column < tableSources.GetLength(1); column++) { tableRow.Append(CreateTextCell(tableSources.GetValue(row, column).ToString())); } table.Append(tableRow); } return(table); }