Report generation in server

48 Views Asked by At

i'm using Microsoft.Office.Interop.Word.Document to generate the report document in server and download it for user.

Is it really good approach to do like this using Interop to perform word operations?. Is it thread safe?. are there any alternatives way you can suggest to perform word operation in server?. I googled lot, found Interop is not safe, you should have word installed in server to generate document etc all issues... But can you please tell me its correct approach or not?

1

There are 1 best solutions below

0
On

Here is an official KB article explaining why it's a bad idea, and listing alternatives:

https://support.microsoft.com/en-us/kb/257757

Is it really good approach to do like this using Interop to perform word operations?

No, it's not - for the reasons listed in that article.

Is it thread safe?

Kind of. Because there are no threads in word API. Word API runs as STA (single-threaded-apartment), so all your API calls will run in one single thread of the word application.

are there any alternatives way you can suggest to perform word operation in server?

First, check out the above article - it has a list of alternatives. There are also libraries which can generate word documents (especially in .docx xml format, there are not that many in the old .doc format).

you should have word installed in server to generate document

Not only you should have it installed on server, but also the user who uses your website (which, in turn, uses Word). Read the article above - it's a licensing requirement.

But can you please tell me its correct approach or not?

It's a bad idea for production.