Manipulating Word documents on server without Office installed (ASP.NET)

36,562

Solution 1

The Interop library is not a "working" library in itself, it is only a wrapper around winword.exe for .NET programs, so using this library does not make any sense if you don't install or use Microsoft Word.

Instead you will need to find a library that allows for manipulating Word Documents. If you can constrain the documents to be in the new format (docx), then it will be quite an easy task, e.g. using the OOXML SDK (as proposed by Stilgar, too). But there are libraries for the old format, too.

Update: I have to admit, although I was convinced I searched and found some libraries for the old doc format before, I do not manage to find those anymore, probably because the result lists is "spoiled" by the many offers for docx. To be clear:

If you can afford to stick to docx (2007 or later) format, you should do that. Office Open XML is a (more or less) open standard based on ZIP and XML, and many tools already exist and will be developed in the future. The old format is much less supported nowadays.

If you have to go for the old format, too, then Aspose (as proposed by Uwe) is the only library I found.

Solution 2

I think the OOXML SDK may contain something but it will only work with docx and not with the old doc.

As for the old formats I am also interested in a cheap and easy way to support them without the need to use the Automation APIs

Solution 3

  1. You should explain better what is the result you want to achieve
  2. NO WAY, MS Office interop needs MS Word do be installed on the server
  3. Depending on you needs, you should find the best 3rd party library (I suggest OpenXml.WordprocessingDocument) but code must be rewritten.
Share:
36,562
Andrej
Author by

Andrej

Updated on July 09, 2022

Comments

  • Andrej
    Andrej almost 2 years

    I'm working on a code to make a MS Word to HTML system. After googleing for about half a minute, I was able to find the code which does exactly what I need. Now.. It works offline on the ASP.NET development server, but it won't work when I upload the files on my server.

    I read a couple of posts, and the problem seems to be becouse the server does not have MS Office installed on it. Now, i'm not sure if it has, i'm still avaiting an email from the good people @ hosting (but i assume it's not installed), but my question is...

    Is there ANY way to make it work without th MS Office installed? I'm using Microsoft.Office.Interop.Word ver. 12. / ASP 3.5 / C# and the error I'm getting is

    Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies.

    Thank you for your time!

  • DarinH
    DarinH over 13 years
    I did a LOT of research into this topic for a recent project I did for a law firm. Aspose is one of the very few packages out that support the older DOC format, and even then, there are some limitations to what they support (esp with respect to Mail Merge fields). The OOXML libraries work quite well for DOCX files and don't require Office, BUT they can be quite challenging to do any kind of significant document alteration. Building docs from scratch is pretty easy with them, though.