0

I've read its not really recommended to use interop office to modify documents server side. The problem is the libraries for this kind of thing are really expensive.

Requirements and implementation in my case:

  • The modified documents must be from office 2003+.
  • Code will run on windows server.
  • Documents will be copied using external code then my class will take that copied document (file path), modify it, save it.
  • There should be no problem with read-only because there will be one document per user.

What kind of problems can be expected?

Can it be a problem if 50 different users use my class at the same time to modify different documents?

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
cah1r
  • 1,751
  • 6
  • 28
  • 47
  • I use the MS Open XML SDK located [here](http://msdn.microsoft.com/en-us/library/office/bb448854(v=office.15).aspx) as it's free and more performant than the Office Interop libraries. – Rob J Dec 21 '14 at 12:44
  • 2
    Memory can be an issue without the correct acquisition and release of objects - the 'two dot' rule should always be borne in mind, and this is well explained [in this question and its answers](http://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects) – dyson Dec 21 '14 at 12:49
  • @RobJ Problem is that it doesn't support office 2003. – cah1r Dec 21 '14 at 12:49
  • We are using the components from Aspose on our server. – Uwe Keim Dec 21 '14 at 13:55
  • @UweKeim It's really expensive. Most of commercial apps are. – cah1r Dec 21 '14 at 15:45

2 Answers2

0

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

You can read more about that in the Considerations for server-side Automation of Office article.

As a workaround you can use:

  1. Open XML SDK for manipulating files that are in open XML format.
  2. Third-party commercial components.
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • I know that Microsoft doesnt reccomend this. I wrote it in the post. The question was about possible workarounds and problems and their solutions. As to 1) doesnt support office 2003 2) Extremely expensive – cah1r Dec 21 '14 at 15:47
  • I'm not looking for a workaround. I've spent quite a lot of time on this issue and I know there isn't. The question was like I said about possible issues that my occur and their solutions. Something that people who used interop might know. – cah1r Dec 22 '14 at 08:43
  • In most cases you will get an exception when calling any property or method from the Office object model. Nobody knows exactly where or when it may happen. – Eugene Astafiev Dec 22 '14 at 08:55
0

Use NPOI to modify .xls documents.

Unfortunately I don't know libraries that work with .doc format.

trailmax
  • 34,305
  • 22
  • 140
  • 234
  • 1
    NPOI works fine for entire office package I think. Problem is it doesn't allow me to do some things I need. Already tried. – cah1r Dec 21 '14 at 15:48
  • Oh. Then you are in trouble! Did not now NPOI works with `.doc` - their web-site only mentions `.docx` and all Excel formats. Good luck with Interop - it is a right pain in the backside -( Unfortunately don't have any advice for using this. – trailmax Dec 21 '14 at 16:15
  • Yea I know I am. NPOI would be a good solution but there is just to many things I tried and didn't find them possible to do. – cah1r Dec 22 '14 at 08:44