Question How to properly create or fill a Word document?

themite

New member
Joined
Aug 7, 2020
Messages
3
Programming Experience
Beginner
Hello,

I would like to ask for an advice. As you can see from the img below I have this Model to populate with some data from my Database. So I would like to ask you what is the best way to accomplish this type of job?
Creating a new one from code behind or use a word document created by me.
Regards

08062020[Untitled]-1.jpg
 
Are you doing this server side or on the desktop? If on the desktop, then the easiest way would be to manipulate an existing document using the Word Object Model. If server side, you'll need to use the OpenXML SDK to either create a new document or modify an existing document; or try to find a 3rd party library that lets your create or modify a document. I mention the 3rd party library option because the learning curve for OpenXML is very steep and documentation on the individual components is highly detailed, but there is no documentation on how to put the pieces together -- which is unfortunately common for Microsoft documentation written at the time as @RobertbNZ will attest to.
 
Are you doing this server side or on the desktop? If on the desktop, then the easiest way would be to manipulate an existing document using the Word Object Model. If server side, you'll need to use the OpenXML SDK to either create a new document or modify an existing document; or try to find a 3rd party library that lets your create or modify a document. I mention the 3rd party library option because the learning curve for OpenXML is very steep and documentation on the individual components is highly detailed, but there is no documentation on how to put the pieces together -- which is unfortunately common for Microsoft documentation written at the time as @RobertbNZ will attest to.


Really appreciate your response, I would like to create the document on the desktop. So you suggest me to use a word document with created tables already and only fill the document from code behind?
 
Yes.

You mentioned "code behind", though. Are you creating a WPF or UWP application as the front end?
 
Have fun!

Mentally it's going to be a clash: very modern way of doing things with WPF meets the 1990's approach of manipulating the Word object model. It's not insurmountable, but it will require you to wear two hats to keep the two different mindsets distinct.
 
Back
Top Bottom