Automating Word Document creation from ASP.NET

M

mc

I've know that Microsoft don't currently recommend this process, what
I'm trying to find out is why?

This is a feature that I've used (with Classic ASP) in the past with a
great deal of success.

Regards


MC
 
E

Eliyahu Goldin

Because of the licensing issues. It shouldn't make any difference what
server-side platform you are using.
 
B

bruce barker \(sqlwork.com\)

because word is not designed for this. you will run into scaling and memory
usage issues.

-- bruce (sqlwork.com)
 
M

mc

Mark said:
Then you've either been very lucky, or your site has had a tiny number of
concurrent connections trying to instantiate Word...

On our current system word is invoked 25-50 times a day, so I'd guess
our success is mainly due to that!
 
M

Mark Rae

because word is not designed for this. you will run into scaling and
memory usage issues.

Quite so, although the OP implies that he has an absolutely tiny hit-rate
(less than 50 a day), so he probably hasn't encountered many problems so
far...
 
M

Mark Rae

On our current system word is invoked 25-50 times a day, so I'd guess our
success is mainly due to that!

I guess so!

On another note, I'm assuming you know that you don't actually *need* Word
at all to create valid Word documents... You don't even need a 3rd-party
utility like Aspose. All you need is the ability to generate XML in the form
that Word understands. Unless your Word documents are *very* complex and/or
*very* large, this can be achieved quite simply and efficiently. If you take
one of your existing Word documents, open it in Word, click Save As and
choose the XML format, you can then open the XML document and see how it's
structured.

Assuming all your users have fairly recent versions of Word (the last two, I
think), if you take such an XML document and give it a .doc extension, Word
will open it directly without any problems...

You can use the same technique for other Office apps e.g. Excel, PowerPoint
etc.
 
S

Steve C. Orr [MVP, MCSD]

Server side COM automation with Office is not recommended or supported by
Microsoft. Here is their official statement on the subject:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

Here are some tips and suggestions for working with Word (and Excel) the
right way:
http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/reviews/AsposeWord.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx
http://msdn.microsoft.com/office/understanding/vsto/
 
M

mc

Mark said:
I guess so!

On another note, I'm assuming you know that you don't actually *need* Word
at all to create valid Word documents... You don't even need a 3rd-party
utility like Aspose. All you need is the ability to generate XML in the form
that Word understands. Unless your Word documents are *very* complex and/or
*very* large, this can be achieved quite simply and efficiently. If you take
one of your existing Word documents, open it in Word, click Save As and
choose the XML format, you can then open the XML document and see how it's
structured.

Assuming all your users have fairly recent versions of Word (the last two, I
think), if you take such an XML document and give it a .doc extension, Word
will open it directly without any problems...

You can use the same technique for other Office apps e.g. Excel, PowerPoint
etc.

Unfortunately I currently use the word automation to create a
complicated document, during the automation I dynamically create tables,
I will however look into this as I like the XML template Idea!

Thanks


MC
 
M

Mark Rae

I will however look into this as I like the XML template Idea!

In almost all situations, it can be an extremely efficient solution.

Obviously, ASP.NET and XML are pretty much "made for each other", so you
almost certainly won't have any problems in actually generating the XML
itself...

Assuming you go down this route and get it working, I would strongly suggest
that you uninstall Word / Office from your webserver, as you will no longer
need it - also, that will mean you will no longer need to worry about
whether you need a separate Word licence for every possible visitor, for
every concurrent visitor only, or just for the server itself... :)
 
M

Mark Rae

After saving my document as XML and looking at the source how do i get
started and programming against the xml document?

Same way you would manipulate any other XML document... The XML schemas for
the Office suite are readily available:
http://www.google.co.uk/search?sour...s=GGLG,GGLG:2006-28,GGLG:en&q=word+xml+schema
if i wanted to take a customer in Northwind and their orders and display
it
in word is this somethng i can do easily with xml tip?

I suppose that really depends on your definition of "easily"...

At the end of the day, XML is XML is XML - if you're fairly familiar with
XML documents and transformations, this will present very little difficulty
to you. If, on the other hand, you've never used XML before, you'll have a
bit of a learning curve - same as you would have with any other technology
new to you...

On the other hand, if you don't need all of the minute detail that the XML
format will give you, you can just as easily (probably much more so!) create
a simple HTML document and give it a .doc extension - that will cause Word
to open it, whereupon it will recognise it as an HTML document and render it
accordingly...

E.g.

1) Open Notepad

2) Paste the HTML below:

<html>
<body>
Hello
</body>
<html>

3) Save it as C:\Test.doc

4) Close Notepad

5) Double-click C:\Test.doc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top