询问者
Interop.PowerPoint.dll 用 C#时 怎么对ppt中的表格 进行设置边框效果?

问题
-
Interop.PowerPoint 用 C#时 怎么对ppt中的表格 进行设置边框效果?
objShape = MySlide.Shapes.AddTable(10, 5, ConvertCmtoPx(4), ConvertCmtoPx(2.5), ConvertCmtoPx(20), ConvertCmtoPx(10));
table = objShape.Table;
table.Columns[1].Width = ConvertCmtoPx(1.5);//列宽
table.Background.Fill.Transparency = 1;////控制填充色为透明
table.Background.Fill.ForeColor.RGB = 0xCC0000;
//table.ApplyStyle("dd",true);
//Borders.Item(PowerPoint.PpBorderType.ppBorderBottom).Visible;
string[] tableRowsName = {"序号", "项目名称", "所属区域", "社区名称", "媒体数量"};
for (int i = 1; i <= table.Rows.Count; i++)
{
for (int j = 1; j <= table.Columns.Count; j++)
{
//table.Cell(i, j).Shape.Line.Weight = 1F;//改变线粗细
//table.Cell(i, j).Shape.Line.Style = MsoLineStyle.msoLineSingle;//改变线型里的复合类型
//table.Cell(i, j).Shape.Line.Weight = 1F;//改变线粗细
//table.Cell(i, j).Shape.Fill.Visible = MsoTriState.msoTrue;
//table.Cell(i, j).Shape.Line.DashStyle = Office.MsoLineDashStyle.msoLineDashDotDot;
//table.Cell(i, j).Shape.Fill.BackColor.RGB = 0xffffff;
table.Cell(i, j).Shape.TextFrame.TextRange.Font.Size = 12;
table.Cell(i, j).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = PowerPoint.PpParagraphAlignment.ppAlignCenter;
table.Cell(i, j).Shape.TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;
if (i == 1)
{
table.Cell(i, j).Shape.TextFrame.TextRange.Text = tableRowsName[j-1];
}
else
{
table.Cell(i, j).Shape.TextFrame.TextRange.Text = string.Format("[{0},{1}]", i, j);
}
}
全部回复
-
嗨,
对于设置边框,你可以用table.Cell(i, j).Borders,下面的代码显示边框。
table.Cell(i, j).Borders[Microsoft.Office.Interop.PowerPoint.PpBorderType.ppBorderTop].ForeColor.RGB= Color.FromArgb(0, 0, 0).ToArgb(); table.Cell(i, j).Borders[Microsoft.Office.Interop.PowerPoint.PpBorderType.ppBorderLeft].ForeColor.RGB = Color.FromArgb(0, 0, 0).ToArgb(); table.Cell(i, j).Borders[Microsoft.Office.Interop.PowerPoint.PpBorderType.ppBorderRight].ForeColor.RGB = Color.FromArgb(0, 0, 0).ToArgb(); table.Cell(i, j).Borders[Microsoft.Office.Interop.PowerPoint.PpBorderType.ppBorderBottom].ForeColor.RGB = Color.FromArgb(0, 0, 0).ToArgb();
这个论坛主要是讨论WCF的开发问题的,如果你有对Office开发的问题,我建议你去下面的论坛发英文帖,那里是专门讨论Office开发的。
Reference:https://social.msdn.microsoft.com/Forums/office/en-US/home?category=officedev
Best Regards,
Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已建议为答案 Edward8520Microsoft contingent staff, Moderator 2017年2月23日 2:05
-
嗨,
如果你的问题解决了,我建议你将解决方案标记为答案,这样其他人遇到这样的问题能快速的找到答案。
Regards,
Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.