Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a Microsoft Word template in C#/visualstudio. I added a button and a table with various cells. I want that one cell populates with certain string, another cell to populate with string and so on, not necessarily the cell containing the button. I also would like to validate the content of cells if changed, so I'd like to know if there is some kind of event which I could use on "cell change" or something like that.

How can read or write text to cells in a word document template in C#/Visual Studio?
Thanks
Posted
Updated 29-May-13 3:39am
v5
Comments
Sergey Alexandrovich Kryukov 28-May-13 17:22pm    
Sorry, this is not a question. What's the problem?
—SA
mcabel 29-May-13 9:36am    
How do I programatically add text to a cell in a word template in visual studio?

 
Share this answer
 
v2
Comments
CHill60 29-May-13 9:40am    
Beat me to it! My +5
Maciej Los 29-May-13 9:49am    
Thank you, Chill ;)
mcabel 29-May-13 14:21pm    
thanks, this seemed to work, although I can't seem to find how to *read*, only write from a cell. How can you read from a cell?

Edit: I found how to do it; Word.Cell objects are Read/write, so I just assign myText = cell.Range.Text;
Maciej Los 31-May-13 11:32am    
You're welcome ;)
How about using Open XML SDK? Please see:
http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard:
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML[^].

This is another option: http://npoi.codeplex.com/[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900