使用.net office word组件

来源:互联网 发布:淘宝官方自营店正品吗 编辑:程序博客网 时间:2024/05/22 14:06
 
注意,这里添加的是com组件,不是.net组件。

1.
.com组件


添加引用:
Microsoft.Office.Interop.Word;



2.
using Word = Microsoft.Office.Interop.Word;

3.
 wordDoc.Tables[1].Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightAtLeast;
                wordDoc.Tables.Item(1).Rows.Height

Tables.Item(1)==>Tables[1]


4.
设置office表格样式


wordDoc.Tables[1].Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
                wordDoc.Tables[1].Borders.OutsideLineWidth= Word.WdLineWidth.wdLineWidth050pt;
                wordDoc.Tables[1].Borders.OutsideColor = Word.WdColor.wdColorAutomatic;




这是一个旧的项目的代码,在vs2010中打开发现问题,主要是对office.word的引用和api的使用。


原创粉丝点击