使用 Office.Interop 在 MS Word 表中添加一行 [英] Add a row to an MS Word table using Office.Interop

查看:29
本文介绍了使用 Office.Interop 在 MS Word 表中添加一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有表格的单词模板,我从使用制表符拆分的字符串列表中填充该表格.

I have a word template with a table that I am populating from a list of strings that I split using tab characters.

我不知道我会有多少行文本,因为它会有所不同.

I do not know how many lines of text I will have as it will vary.

所以我在像这样遍历我的循环之前以编程方式添加一行:

So I am adding a row programmatically before iterating through my loop like this:

oWordDoc.Tables[2].Rows.Add(oWordDoc.Tables[2].Rows[1]);

不幸的是,它是在当前行之前而不是在当前行之后添加行.

Unfortunately it is adding the row before rather than after the current row.

如何更改我的代码以始终在当前行之后添加一个空行?

How can I change my code to always have an empty row added after the current row?

推荐答案

我找到了,应该是:

Object oMissing = System.Reflection.Missing.Value;
oWordDoc.Tables[2].Rows.Add(ref oMissing); 

这篇关于使用 Office.Interop 在 MS Word 表中添加一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆