question

mitenikolov-7932 avatar image
0 Votes"
mitenikolov-7932 asked ·

How to properly create a Word or PDF document with values from DataBase

Hello,


I would like to ask for an advice. I have this model below that I need to create and fill it with some values from my DataBase.
What is the best way to accomplish this type of job? I've already tried to design the table directly on the form and print the form later, but sometimes the DataGridView is too long so my Form goes out of limits and it print only the parts that is seen on the Monitor.

An advice would be really appreciated..

Regards


16193-08062020untitled-1.jpg


windows-forms
· 3
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Are you developing a Windows Forms app or a WPF app? Then you want to show the values in the app like a word or excel?

0 Votes 0 ·

Yes I'm developing a Windows Froms app. Yes I would like to show the values in the app like word or excel, but I don't know what is the best way to create this...

0 Votes 0 ·

Hi mitenikolov,
Has your problem been solved? If it is resolved, we suggest that you mark it as the answer. So it can help other people who have the same problem find a solution quickly.
Best Regards,
Daniel Zhang

0 Votes 0 ·

1 Answer

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered ·

Hi mitenikolov,
You can use Microsoft.Office.Interop.Word to put data in datagridview into word.
First, you need to add Microsoft.Office.Interop.Word reference by following steps:
Right click the project-> Manage NugetPackages->Browse-> Enter the "Microsoft.Office.Interop.Word" into the search box -> Install it.
Here is a code example you can refer to.17103-test-2.txt
Best Regards,
Daniel Zhang



test-2.txt (3.8 KiB)
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.