简体   繁体   English

C#Power Point一次更改表格单元格字体

[英]C# Power Point change Table Cell Fonts at once

I create a table in Excel and then copy it to Powerpoint. 我在Excel中创建一个表,然后将其复制到Powerpoint。 Then I edit the table cell fonts. 然后,编辑表格单元格字体。 If you do it interactively you can select the table and set any font size, but using C#, I couldn't do the same thing. 如果您以交互方式进行操作,则可以选择表格并设置任何字体大小,但是使用C#,我做不到相同的事情。 Now I'm setting font size of each cell one by one, but if the table is large it is taking a lot of time. 现在,我逐个设置每个单元格的字体大小,但是如果表很大,则要花费很多时间。 Is there any way to set the table font size at once. 有什么方法可以一次设置表格字体大小。 Here is the code I'm using now which is very slow: 这是我现在正在使用的代码,它非常慢:

for (int i = 1; i <= rows.Count; i++)
for (int k = 1; k <= cols.Count; k++)
{
    shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Size =  fontSize;
    shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Name = fontName;
    shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Bold = bold;
    shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Color.RGB = color;
} 
shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Size =  8;
shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Name = "Arial (Body)";
shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Bold = MsoTriState.msoTrue;
int oleColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
shp.Table.Cell(row, col).Shape.TextFrame.TextRange.Font.Color.RGB = oleColor;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM