Discussion Locked

Creating Word Doc from HTML Form Pages

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Firstly, I am not sure I have posted this to the right group but here goes anyway.
I am developing an Intranet site for a client where I need to generate a Word
document (preferably at the client end) from the contents of web based form
entry. This word document is required by the user and needs to be also emailed to
another internal email address from the client end (in other words using the
current users email profile in outlook)
Can anyone give me some tips or pointers to where I might find some examples or
documentation on how to achieve this?
I wait with baited breath!...
Jeff

Jeff Simcock - Software n Database Consultant
Odyssey Solutions Pty Ltd - Perth WA Australia
ph: +61 8 9443 3793 mob: +61 0419 042 180 fax: +61 8 9201 0379
web: www.odysol.com.au email: jeffs@odysol.com.au

3 replies

by vcsekhar007

Hi Jeff,
Go through the following :
---------------------------------------------
There is an elegantly simple and little-known way to get information from the server into Excel and Word, available in Office 97 and later versions. The key: Content-type. Excel and Word both can interpret HTML. This little trick means that you can use exactly the same ASP file and output it to Word, Excel, or the browser just by setting the content-type. Once it's in the viewer's Office applications, the viewer can do whatever he or she might want to do with any Office document, except save it back to the server.One limitation is that you can display only a single Excel sheet, rather than a workbook full. Because this is all simple HTML, the files are quite small. This makes a great, lightweight method of making reports available to those who might have slow connections.
Here is a simple example:

<%@ language=vbscript %><%response.buffer = true
response.ContentType = "application/vnd.ms-excel"
response.AddHeader "content-disposition", "inline; filename=dynamic.xls"
response.write "

"
response.write "

"
for i = 1 to 4
response.write "

"next
response.write "

"
response.write "

"
response.write "

"
response.write i + i
response.write "
=sum(A1:D1)

"
response.flush
response.end%>
There are several cool things to notice here.
The fourth line of the code does the magic of telling the browser which application to open. To open Word, you would change the content-type to application/vnd.ms-word.The fifth line of the code is a response.addHeader. This line specifies the file name to display if the user chooses to save, rather than open, the file.The line after the end of the for loop contains a sum formula that Excel will act upon correctly?and because of the tags that surround it, it will be disp

This discussion is closed to new replies.