Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a Word document be created in C#? [closed]

I have a project where I would like to generate a report export in MS Word format. The report will include images/graphs, tables, and text. What is the best way to do this? Third party tools? What are your experiences?

like image 460
Schmidty Avatar asked Aug 13 '08 22:08

Schmidty


People also ask

How is Word document created?

Open Word. Or, if Word is already open, select File > New. In the Search for online templates box, enter a search word like letter, resume, or invoice. Or, select a category under the search box like Business, Personal, or Education.


2 Answers

The answer is going to depend slightly upon if the application is running on a server or if it is running on the client machine. If you are running on a server then you are going to want to use one of the XML based office generation formats as there are know issues when using Office Automation on a server.

However, if you are working on the client machine then you have a choice of either using Office Automation or using the Office Open XML format (see links below), which is supported by Microsoft Office 2000 and up either natively or through service packs. One draw back to this though is that you might not be able to embed some kinds of graphs or images that you wish to show.

The best way to go about things will all depend sightly upon how much time you have to invest in development. If you go the route of Office Automation there are quite a few good tutorials out there that can be found via Google and is fairly simple to learn. However, the Open Office XML format is fairly new so you might find the learning curve to be a bit higher.

Office Open XML Iinformation

  • Office Open XML - http://en.wikipedia.org/wiki/Office_Open_XML
  • OpenXML Developer - http://openxmldeveloper.org/default.aspx
  • Introducing the Office (2007) Open XML File Formats - http://msdn.microsoft.com/en-us/library/aa338205.aspx
like image 159
rjzii Avatar answered Oct 02 '22 05:10

rjzii


DocX free library for creating DocX documents, actively developed and very easy and intuitive to use. Since CodePlex is dying, project has moved to github.

like image 41
MadBoy Avatar answered Oct 02 '22 04:10

MadBoy