tags:

views:

792

answers:

8

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?

A: 

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

Galwegian
fails, no powerpoint
+1  A: 

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

Conrad
fails, costs a fortune
There's no free lunch i'm afraid. You have to pay SOME price -- actual money, development effort, stability ... you have to pick your poison
Conrad
seems we are using the best tool for the job under the circumstances then
A: 

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

Kev
fails, costs a fortune
A: 

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

Joe Erickson
fails, no word, no powerpoint
A: 

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.

Chris Mullins
fails, not creating real office files
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.
RichardOD
A: 

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 atleast.

HTH

OneSHOT

OneSHOT
fail, same limitations, seem to be discontinued http://support.microsoft.com/kb/317316
+1  A: 

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.

Cocowalla
A: 

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