问题
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)?
回答1:
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);
来源:https://stackoverflow.com/questions/4736292/setting-word-2007-table-style-designs-in-code