By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,184 Members | 1,500 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,184 IT Pros & Developers. It's quick & easy.

How to populate a word file from within ASP.NET and stream it out to the client?

P: n/a
Hi,

I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed).
The preferable solution would be to have a word template on the server which is populated in the asp.net application and then streamed out to the user.
Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible).

Does anybody know how this can be done? Which way would be preferable? Create the file on the server and streaming it out to the user or using automation to populate a file on the client's computer?
I know that it's possible to sent html to excel (via automation) which is then nicely rendered (like in the following example).

<script language="vbscript">
Sub Button1_onclick()
Dim sHTML
sHTML = window.Form1.children("DataGrid1").outerhtml
Dim oXL, oBook
Set oXL = CreateObject("Excel.Application")
Set oBook = oXL.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oXL.Visible = true
oXL.UserControl = true
end sub
</script>

Is there something similar possible with word? If


Thank you a lot for your help!

Daniel Walzenbach
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
This article demonstrates a number of techniques for generating Excel and Word documents.
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

Here's a good 3rd party product you could use if you need to get really fancy:
http://www.aspose.com/Products/Aspose.Word/
And here's another:
www.officewriter.com

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Daniel Walzenbach" <da**********************@freudenberg.de> wrote in message news:uK**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed).
The preferable solution would be to have a word template on the server which is populated in the asp.net application and then streamed out to the user.
Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible).

Does anybody know how this can be done? Which way would be preferable? Create the file on the server and streaming it out to the user or using automation to populate a file on the client's computer?
I know that it's possible to sent html to excel (via automation) which is then nicely rendered (like in the following example).

<script language="vbscript">
Sub Button1_onclick()
Dim sHTML
sHTML = window.Form1.children("DataGrid1").outerhtml
Dim oXL, oBook
Set oXL = CreateObject("Excel.Application")
Set oBook = oXL.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oXL.Visible = true
oXL.UserControl = true
end sub
</script>

Is there something similar possible with word? If


Thank you a lot for your help!

Daniel Walzenbach
Nov 18 '05 #2

P: n/a
Steve,



Thank you for your immediate answer. Could you please tell me what I would have to do if I wanted to use automation and be able to access some fields within a template? How would I have to declare those fields and how could they be accessed?



Thank you!

Daniel

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> schrieb im Newsbeitrag news:OI**************@TK2MSFTNGP10.phx.gbl...
This article demonstrates a number of techniques for generating Excel and Word documents.
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

Here's a good 3rd party product you could use if you need to get really fancy:
http://www.aspose.com/Products/Aspose.Word/
And here's another:
www.officewriter.com

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Daniel Walzenbach" <da**********************@freudenberg.de> wrote in message news:uK**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed).
The preferable solution would be to have a word template on the server which is populated in the asp.net application and then streamed out to the user.
Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible).

Does anybody know how this can be done? Which way would be preferable? Create the file on the server and streaming it out to the user or using automation to populate a file on the client's computer?
I know that it's possible to sent html to excel (via automation) which is then nicely rendered (like in the following example).

<script language="vbscript">
Sub Button1_onclick()
Dim sHTML
sHTML = window.Form1.children("DataGrid1").outerhtml
Dim oXL, oBook
Set oXL = CreateObject("Excel.Application")
Set oBook = oXL.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oXL.Visible = true
oXL.UserControl = true
end sub
</script>

Is there something similar possible with word? If


Thank you a lot for your help!

Daniel Walzenbach
Nov 18 '05 #3

P: n/a
Hi Daniel,

There are some tech articles discussing on using Automation to process Word
document in .net:

#HOW TO: Automate Word from Visual C# .NET to Create a New Document
http://support.microsoft.com/default.aspx?id=316384

#Microsoft Word Documents from ASP.NET
http://www.codeproject.com/aspnet/wordapplication.asp

However, in ASP.NET Web application, since web application is serverside
application and the Automation is strongly not recommended. And it'll cause
many unexpected issues which may occur randomly. Here is the kb article
mentioned the concerns:

#INFO: Considerations for Server-Side Automation of Office
http://support.microsoft.com/default...b;EN-US;257757

In addition, I still recommend that you consider some other means to
generate word document such as transfer XML document or other components if
you feel appropriate. And here is another kb article discussing use XSL
TRANSFORM to generate word document;

#HOW TO: Use ASP.NET or Visual Basic.NET to Transform XML To Rich Text
Format (RTF) For Microsoft Word 2002
http://support.microsoft.com/default...b;en-us;311461

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4

P: n/a
For that kind of functionality in a web application I'd have to recommend one of the 3rd party products I mentioned. They both support your requirements.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Daniel Walzenbach" <da**********************@freudenberg.de> wrote in message news:eb**************@TK2MSFTNGP12.phx.gbl...
Steve,



Thank you for your immediate answer. Could you please tell me what I would have to do if I wanted to use automation and be able to access some fields within a template? How would I have to declare those fields and how could they be accessed?



Thank you!

Daniel

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> schrieb im Newsbeitrag news:OI**************@TK2MSFTNGP10.phx.gbl...
This article demonstrates a number of techniques for generating Excel and Word documents.
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

Here's a good 3rd party product you could use if you need to get really fancy:
http://www.aspose.com/Products/Aspose.Word/
And here's another:
www.officewriter.com

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Daniel Walzenbach" <da**********************@freudenberg.de> wrote in message news:uK**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed).
The preferable solution would be to have a word template on the server which is populated in the asp.net application and then streamed out to the user.
Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible).

Does anybody know how this can be done? Which way would be preferable? Create the file on the server and streaming it out to the user or using automation to populate a file on the client's computer?
I know that it's possible to sent html to excel (via automation) which is then nicely rendered (like in the following example).

<script language="vbscript">
Sub Button1_onclick()
Dim sHTML
sHTML = window.Form1.children("DataGrid1").outerhtml
Dim oXL, oBook
Set oXL = CreateObject("Excel.Application")
Set oBook = oXL.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oXL.Visible = true
oXL.UserControl = true
end sub
</script>

Is there something similar possible with word? If


Thank you a lot for your help!

Daniel Walzenbach
Nov 18 '05 #5

P: n/a
All right,

Thank you Steve!
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> schrieb im Newsbeitrag news:O3**************@TK2MSFTNGP10.phx.gbl...
For that kind of functionality in a web application I'd have to recommend one of the 3rd party products I mentioned. They both support your requirements.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Daniel Walzenbach" <da**********************@freudenberg.de> wrote in message news:eb**************@TK2MSFTNGP12.phx.gbl...
Steve,



Thank you for your immediate answer. Could you please tell me what I would have to do if I wanted to use automation and be able to access some fields within a template? How would I have to declare those fields and how could they be accessed?



Thank you!

Daniel

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> schrieb im Newsbeitrag news:OI**************@TK2MSFTNGP10.phx.gbl...
This article demonstrates a number of techniques for generating Excel and Word documents.
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

Here's a good 3rd party product you could use if you need to get really fancy:
http://www.aspose.com/Products/Aspose.Word/
And here's another:
www.officewriter.com

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Daniel Walzenbach" <da**********************@freudenberg.de> wrote in message news:uK**************@TK2MSFTNGP09.phx.gbl...
Hi,

I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed).
The preferable solution would be to have a word template on the server which is populated in the asp.net application and then streamed out to the user.
Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible).

Does anybody know how this can be done? Which way would be preferable? Create the file on the server and streaming it out to the user or using automation to populate a file on the client's computer?
I know that it's possible to sent html to excel (via automation) which is then nicely rendered (like in the following example).

<script language="vbscript">
Sub Button1_onclick()
Dim sHTML
sHTML = window.Form1.children("DataGrid1").outerhtml
Dim oXL, oBook
Set oXL = CreateObject("Excel.Application")
Set oBook = oXL.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oXL.Visible = true
oXL.UserControl = true
end sub
</script>

Is there something similar possible with word? If


Thank you a lot for your help!

Daniel Walzenbach
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.