Alternative to Office Interop for document generation
Asked Answered
K

8

7

At the moment we're using office interop to generate documents from templates in office 2003 (word, excel & powerpoint). This seems to be rather frowned upon (see office-interop-with-64bit-windows-in-asp-net) and whilst it works fine I would be happier with a supported solution.

What non hacky method is there to do this? Requirements are

  1. Office 2003 only. (No office xml / office 2007 compatability pack allowed)
  2. Must run server side from ASP.NET
  3. Must be able to create Word, Excel & Powerpoint documents from user supplied .dot, .xlt and .pot templates
  4. Must be able to further customise the docouments by replacing certain text at certain points e.g. names, addresses etc
  5. Free or very low cost. I'm not going to be able to raise a purchase order to replace a working system on the grounds that four people on some website thought it was a dirty hack ;)

I'm not sure there is a better way. Is there?

Korwun answered 24/6, 2009 at 16:28 Comment(0)
B
5

I just posted this as an answer to another question about automating Office, but I think it's a suitable response to this question too (especially since you are looking for a free or low cost solution).

I've had no end of problems (poor performance, hanging processes, crashing processes etc) using Microsoft Excel, Word and PowerPoint through interop in a web service to print Office documents to PDF format. I too have faced problems that I suspect are because of invisible dialog boxes (maybe a file is corrupt, read-only recommended has been set, file is password protected, or whatever).

I know there are tools available that don't use Office, but they are very expensive. My solution was to switch to automating OpenOffice. OpenOffice seems to be much more stable, and I've left hanging processes and the like behind.

So, while I suppose I am saying "don't automate Microsoft Office", I'm not suggesting that you abandon automation altogether; just that I've had much more success automating OpenOffice than Microsoft Office.

Bruxelles answered 8/9, 2009 at 13:44 Comment(0)
F
1

Aspose have a number of components in .NET and Java for generating Word, Excel and Powerpoint documents

Fideliafidelio answered 24/6, 2009 at 16:38 Comment(3)
There's no free lunch i'm afraid. You have to pay SOME price -- actual money, development effort, stability ... you have to pick your poisonFideliafidelio
seems we are using the best tool for the job under the circumstances thenKorwun
there's a huge range between free lunch and steak dinner with shrimp and lobster stuffed with gold dust, which is how I would describe Aspose's pricing.Johansen
B
1

You should take a look at the products available from Aspose. There are a number of different file format components that allow you to create and manipulate PDF and Microsoft Office documents without requiring Office to be installed on the server:

File Format Components (Aspose)

Software Artisans have some similar components that can read and write Word and Excel documents:

Software Artisans OfficeWriter

Brenner answered 24/6, 2009 at 16:40 Comment(1)
OfficeWriter link doesn't work. Nevertheless what it their price, the price list is empty... is it absurd as the Aspose? Anyway, I happing with GemBox libraries, they are cheaper.Lesslie
H
1

Take a look at http://npoi.codeplex.com/ I use it to create excel documents. supports ppt and word as well.

Heterochromatic answered 16/9, 2009 at 6:1 Comment(0)
T
0

If you have SQL Server, you could look at SQL Server Reporting Services

Timon answered 24/6, 2009 at 16:34 Comment(0)
E
0

SpreadsheetGear for .NET can handle the Excel file generation. We focus on spreadsheets so we do not have Word or PowerPoint generation.

You can see ASP.NET samples here and download a free trial here.

Disclaimer: I own SpreadsheetGear LLC

Edmond answered 24/6, 2009 at 16:42 Comment(0)
V
0

One way we have done this, but not with template files is to create your document template and save it as a word, excel, or ppt document, but in a format where the document remains in human readable text. So for Word and Excel save as mht.

Then you can read in the template as a string, and process it with good old fashioned string manipulation functions (replace placeholder text, add rows whatever you need to do) then save the string as a .doc, .xls, or .ppt (which ever program created it) file and it should open right back up as a document in that application with all your formatting intact.

One tip, you have to check your template in a text editor after you save it in Word. Word will indiscriminately add line breaks so it may line break your placeholders or put other formatting inside them which you may have to clean up.

Vientiane answered 25/6, 2009 at 12:1 Comment(2)
fails, not creating real office filesKorwun
I tried this once with Office 2003 XML, but I found it often put sentences for no apparent reason across multiple XML tags, which made it a pain to template.Abducent
M
0

Have a look at OWC (office web components) these were designed for what you are looking to do!

I don't know if they can work with templates as it's ages since i have used them but we used to generate spread sheets on the fly then binary write them to the response stream to display them in the browser.

I'm not sure if they will completely meet your requirements but worth looking into as a start at least.

Myra answered 25/6, 2009 at 12:13 Comment(1)
fail, same limitations, seem to be discontinued support.microsoft.com/kb/317316Korwun

© 2022 - 2024 — McMap. All rights reserved.