C#Word模板向各种单元格添加信息 [英] C# Word template add information to various cells

查看:118
本文介绍了C#Word模板向各种单元格添加信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#/ visualstudio中有一个Microsoft Word模板。我添加了一个按钮和一个包含各种单元格的表格。我希望一个单元格填充某些字符串,另一个单元格填充字符串等等,不一定是包含该按钮的单元格。如果有变化,我也想验证细胞的内容,所以我想知道是否有某种事件可以用于细胞更换或类似的东西。



如何在C#/ Visual Studio中读取或写入单词文档模板中单元格的文本?

谢谢

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

推荐答案

看看这里:

如何:以编程方式添加文本和格式化到Word表格中的单元格 [ ^ ]

如何:以编程方式将文本插入Word文档 [ ^ ]

如何:将文本插入Word文档 [ ^ ]



其他一些可能有用的链接:

演练:在Word中创建表 [ ^ ]

如何:定义和选择文档中的范围 [ ^ ]

如何:扩展范围文件 [ ^ ]



有关MS Word中事件的一些有用信息:

通过事件控制Microsoft Word [ ^ ]

文档事件 [ ^ ]

如何使用Visual C#.NET处理Word事件 [ ^ ]

你会发现out,没有事件跟踪单元格文本更改;(
Have a look here:
How to: Programmatically Add Text and Formatting to Cells in Word Tables[^]
How to: Programmatically Insert Text into Word Documents[^]
How to: Insert Text into Word Documents[^]

A few other links that could be helpful:
Walkthrough: Creating a Table in Word[^]
How to: Define and Select Ranges in Documents[^]
How to: Extend Ranges in Documents[^]

Some useful information about events in MS Word:
Take Control of Microsoft Word Through Events[^]
Document Events[^]
How To Handle Events for Word by Using Visual C# .NET[^]
As you''ll find out, there is no event to track cell-text change ;(


如何使用Open XML SDK?请参阅:

http://www.microsoft.com /en-us/download/details.aspx?id=30425 [ ^ ]。



这样,您可以支持新的基于XML的Office格式(例如.DOCX ,.XLSX),ECMA-376标准:

http://en.wikipedia.org/wiki/ Microsoft_Office_XML_formats [ ^ ],

http://en.wikipedia.org/wiki/Office_Open_XML [ ^ ]。



这是另一种选择: http://npoi.codeplex.com/ [ ^ ]。



-SA
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


这篇关于C#Word模板向各种单元格添加信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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