473,698 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.binary write, 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 1909
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 "applicatio n/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?

"MstrContro l" 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 "applicatio n/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 = someFileContent sString

Response.Conten tType = "applicatio n/word"
Response.AddHea der "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
8023
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 by changing the content type in the response object. On one of the screens where they enter data, they also have the ability to upload a word document containing additional information. This is also not a problem, and is working fine. Now they...
4
12573
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)"; document.getElementById('myelement') = new Function("myfnc(param1,param2,param3)");
9
39773
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 another "record" the values for all previous controls within the div are wiped out. In the javascript function where I add on to the html in the div if I capture all the data in the previous "records" then after adding the new record I can...
2
1936
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 like the secretary at a school to update a Word document concerning homework assignments. This Word document would reside on the server. When changes are made it, these changes are automatically updated to the web page. This would simplify life...
3
4232
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, I'm uing the coe below, but I'm unsure as to what the Range parameter should be for oWordDoc.Content.Tables.Add ???
3
318
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 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....
5
2872
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 elements in the form, including those that are added dynamically. I use document.getElementsByName('Field Name')to achieve the same.
0
7795
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 assumption here, that anyone looking for this kind of solution would just want a simple example that they can work from and expand upon. In my case, I just want to output a new Word document. I found that creating a simple wrapper class would make this...
7
4867
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 buttons and check box. I am adding two radio buttons once for a row.Now my problem is the radio buttons in all the rows that added dynamically are behaving as same group i.e when i am selecting a radio button in second row,radio button in first row...
0
8673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9021
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4365
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.