gpt4 book ai didi

c# - 如何使用 C# 互操作库在 PowerPoint 中添加表格?

转载 作者:太空宇宙 更新时间:2023-11-03 12:32:05 28 4
gpt4 key购买 nike

我正在使用 C# 动态创建 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);
}

}

那么,如何设置表格边框样式呢?

最佳答案

您可以在 for 循环中添加以下代码片段来调整单元格边框粗细、线条类型、颜色、阴影等。除了 DashStyle、ForeColor 等之外,还有更多项目可供选择。

table.Cell(i, j).Borders[Microsoft.Office.Interop.PowerPoint.PpBorderType.ppBorderLeft].DashStyle = MsoLineDashStyle.msoLineLongDashDot;
table.Cell(i, j).Borders[Microsoft.Office.Interop.PowerPoint.PpBorderType.ppBorderLeft].ForeColor.RGB = 0xff00ff;
table.Cell(i, j).Borders[Microsoft.Office.Interop.PowerPoint.PpBorderType.ppBorderLeft].Weight = 1.0f;

关于c# - 如何使用 C# 互操作库在 PowerPoint 中添加表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42360305/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com