473,371 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,371 software developers and data experts.

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

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
5 2487
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Asma | last post by:
Dear Sir, I am trying to find a way to open a Word document using C language and read the text of word doc into a variable. (Turbo C on Dos 6.0). Can anyone please tell me which libraries in...
6
by: Chris | last post by:
Hi, - How can I open an existing word document from a C#-client and manipulate that document from within the C#-client ? - How can I open an excel document that is embedded in a word-document...
3
by: Skwish | last post by:
Hi, I would like to download all the files from a folder (of various types i.e. ..txt, .dll, .dat, etc.). I tried Dim MyDir As IO.Directory Dim path As String = Me.MapPath(".") & "\Data" Dim...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
4
by: Simon Cheng | last post by:
Hi, How do I open a Word or Excel document inside an event handler (e.g., Page_Load())? Thanks, Simon
12
by: Rob Nicholson | last post by:
We've implemented functionality to allow a user to download a document (any document type) from the IIS server using the following code: Response.Clear() Response.ContentType =...
11
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and...
10
by: David | last post by:
I have googled to no avail on getting specifically what I'm looking for. I have found plenty of full blown apps that implement some type of file transfer but what I'm specifcally looking for is an...
5
by: Nitin Mahajan | last post by:
Guys Is there a way in C# to create a word object directly from a memory stream without passing that to hard disk (file stream). I think it doesn't makes sense to create a file just to read it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.