We recommend two links:
Http://www.codeproject.com/aspnet/wordapplication.asp
Http://www.c-sharpcorner.com/UploadFile/mgold/WordFromDotNet11082005235506PM/WordFromDotNet.aspx
In fact, we can find more in-depth information on the Internet. If we just draw data from dataset to a simple application like word, then the two articlesArticleIt may be suitable. In addition, Let's record two of my experiences:
1. Define wordapp and worddoc
// It's a reference to the COM Object of Microsoft Word application
Private Word. applicationclass owordapplic;
// It's a reference to the document in use
Private Word. Document oworddoc;
codeproject is defined as follows. Other methods are also available in other documents, such as:
word. application owordapp; (this method seems to conflict with quit, and will prompt during compilation) or word. _ application owordapp;
likewise, the document definition is the same:
word. _ document oworddoc; or word. documentclass oworddoc;
of course, if you use word. documentclass, using wordapp. documents. the add () method forcibly converts the return value to word. documentclass.
it's confusing to have a look at it. In fact, the methods are the same. You can see how they are define;
Public interface _ document
{...}
Public interface document: _ document, incluentevents_event
{...}
public class documentclass: _ document, document, documentevents_event
{...}
Public interface _ application
{...}
Public interface application: _ application, applicationevents2_event
{...}
public class applicationclass: _ application, application, applicationevents2_event, applicationevents_event
{...}
2. About word. table
in word, if you press enter directly at the end of the table, a new row is added to the table while the line breaks. Similarly, this problem occurs when we use the Program to operate the word. If another table is inserted immediately after the table, then the two tables are merged into one. If you want to separate tables, you can insert a space to separate them.
another question is, how can I insert the table title on each table? Kindly advise.