开发者

Setting Word 2007 table style designs in code

开发者 https://www.devze.com 2023-02-05 06:29 出处:网络
I am generating a Word document using Microsoft.Office.Interop.Word. In that word document I am generating a table.

I am generating a Word document using Microsoft.Office.Interop.Word. In that word document I am generating a table. I would like 开发者_高级运维to set the table style to one of the nice table design presets in Word 2007+ with alternating row colors, etc.

Rather than setting all the style properties myself, is there an easier way to do this (preset name or some style snippet repository)?


Nevermind, I found it in the manual.

Solution:

            object tableStyle = WdBuiltinStyle.wdStyleTableLightShadingAccent1;
            table.set_Style(ref tableStyle);

or in C# 4:

            table.set_Style(WdBuiltinStyle.wdStyleTableLightShadingAccent1);
0

精彩评论

暂无评论...
验证码 换一张
取 消