Setting Word 2007 table style designs in code
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);
精彩评论