473,406 Members | 2,356 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,406 software developers and data experts.

Dynamically creating a Word document

I want to create a Word document that will display data from a database. I
don't want to create the file on the server, I just want to stream it out
directly to the user. When they click a button, the Word Save Open window
will open, and allow the user to Save or Open the document in Word. I know I
need to use response.binarywrite, but I don't know if it is possible to
create the binary object without first saving it to a temporary file. Would
I need to create a Word template, and how would I use it?

How would I get data from a data grid into this document?
Aug 24 '05 #1
3 1897
Hi Leonard...

There IS a possibility of doing what you want with the most recents
versions of Word (i.e. from Office XP and above), but it has no
backwards compatibility.

You CAN simple set the ResponseType to "application/word" and send an
XML document that mimics the Word new XML document file type.

Just create a new document and save as an XML file and see the output.

Regards,

Paulo

Aug 24 '05 #2
Hi Paulo,
Does that mean I still have to create a file, enen if it is temporary? I
would create the file on my app server, and then use ResponseType
application/word to send it to the user, so the user would not need the
latest version, correct? So, I would need to create the word document, using
xml, and some text, but couldn't I just save to a .doc file?

"MstrControl" wrote:
Hi Leonard...

There IS a possibility of doing what you want with the most recents
versions of Word (i.e. from Office XP and above), but it has no
backwards compatibility.

You CAN simple set the ResponseType to "application/word" and send an
XML document that mimics the Word new XML document file type.

Just create a new document and save as an XML file and see the output.

Regards,

Paulo

Aug 25 '05 #3
You shouldn't have to create a temp file on the server side, some sites
do this for various reasons, but as long as you can create the file in
a file object of some kind (or even just store the file contents in a
variable), then you can stream the download to the requesting user.

Things to look at for this:

Dim fileName, fileContents

fileName = "myfile.doc"
fileContents = someFileContentsString

Response.ContentType = "application/word"
Response.AddHeader "content-disposition", "attachment; filename=" &
fileName
Response.Write fileContents
Response.End
We have this grouped in a procedure where we just pass in the filename
and the filecontents, you could expand to include the filetype to make
it more generic.

Aug 25 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kerri McDonald | last post by:
We have an application where the user fills out many screens and when they are done, we are supposed to display the text they entered in a word or excel format. That is fairly easily accomplished...
4
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
9
by: Michelle | last post by:
I have a div that is initially empty. Clicking on a button will add some text boxes and other controls so the user can add additional records. In IE all works fine but in Netscape 7.0 when I add...
2
by: KnotKnormal | last post by:
I would like to dynamically load a HTML page (or a Word document), which is embedded in a table when the user clicks on a hyperlink to go from HTML page one to HTML page two. For example, I would...
3
by: m3ckon | last post by:
Hi there, I can succesfully create a word doc from my asp.net page, but I have 2 issues I need to resolve in order to use it in my app: 1) Creating a table: I seem unable to create a table,...
3
by: Leonard | last post by:
I want to create a Word document that will display data from a database. I don't want to create the file on the server, I just want to stream it out directly to the user. When they click a...
5
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the...
0
by: PracticalApps | last post by:
I looked to find a canned solution to create a Word document in my application and just couldn't find anything that just gets to the point. I would think, and I may be making too strong of an...
7
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.