1
我使用C#動態創建一個PowerPoint,我需要創建一個包含變量行和列的表格下面的代碼創建表格。如何使用C#interop庫在PowerPoint中添加表格?
objShape = MySlide.Shapes.AddTable(10, 5, ConvertCmtoPx(4), ConvertCmtoPx(2.5), ConvertCmtoPx(15), ConvertCmtoPx(10));
table = objShape.Table;
for (int i = 1; i <= table.Rows.Count; i++)
{
for (int j = 1; j <= table.Columns.Count; j++)
{
table.Cell(i, j).Shape.Fill.Solid.SolidFill.BackColor.RGB = 0xffffff;
table.Cell(i, j).Shape.TextFrame.TextRange.Font.Size = 12;
// table.Cell(i, j).Shape.Line.Style.BackColor.RGB = 0xFF3300;
table.Cell(i, j).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = PowerPoint.PpParagraphAlignment.ppAlignCenter;
table.Cell(i, j).Shape.TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;
table.Cell(i, j).Shape.TextFrame.TextRange.Text = string.Format("[{0},{1}]", i, j);
}
}
現在,如何設置表格邊框的風格?
嘗試之後,您的代碼是正確的 – doo0301