Setting Word 2007 table style designs in code

雨燕双飞 提交于 2019-12-13 03:12:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!