2013-05-08 126 views
0

我在c#中使用Word.Interop将数据注入到word文档中,作为我的模板。 本文档有一张我希望填写的表格。 这样的: enter image description here在c#中使用word interop在word表格中添加文本

我将这样的文本(simpilified):

String text = "1" + "\t" + "2" + "\t" ; //Etc.. 

但是,这是行不通的。

任何想法我应该怎么做?

回答

2

这是行不通的。如果你想在Word文档中创建一个新表,设置要创建的表的文档中的书签,然后创建表如下所述:

http://msdn.microsoft.com/en-us/library/vstudio/w1702h4a.aspx

如果您有现有的在文档中固定表格,将自定义文档属性放置在单元格中,然后设置它们的值如下:

thedocument.CustomDocumentProperties["NameOfTheCustomProperty"].Value = 1; 
+0

感谢您的回答。这是一张现有的桌子。你能解释一下我怎样才能在表格中设置服装配件?另外,是否可以将图片插入到这样的单元格中? – 2013-05-09 06:53:57

+1

看看这个链接:http://office.microsoft.com/en-us/word-help/view-or-change-the-properties-for-an-office-file-HA010354245.aspx#_View_or_create – 2013-05-13 12:34:08

+1

至于图片...不,你需要用范围或书签来说话:http://nishantrana.wordpress.com/2008/07/17/opening-and-inserting-a-picture-in-word-document-programmatically - 使用-C / – 2013-05-13 12:37:04

相关问题