当前位置: 网学 > 编程文档 > ASP > 正文

用ASP创建Word文件

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/17
下载{$ArticleTitle}原创论文样式

Using Active Server Pages to Build Microsoft Word Documents  
By Gardiner B. Jones  

Background  
BuildDoc.asp is an Active Server Page (asp) that reads the output of a

Web page form, and creates as output a Microsoft Word document contai

ning a table of changed data within the form. Forms are no longer limi

ted to containing static information. With database connectivity, the  

increasing use of Dynamic HTML (DHTML), and the growing interest in XM

L, it has become common practice in business Web pages for the data co

ntained in them to be dynamic. That is, what is shown in the form may  

change based on user interaction (see the sample input form below).  



The business need filled by BuildDoc is to enable sales associates to  

create form letters from the changed records of a Web page table. Only

the data modified by the sales person is sent to Word, where it is fo

rmatted into a table. Obviously, all samples here are fictitious.  

BuildDoc will read all of the information on the form, identifying whi

ch rows have been changed, and then creates the Microsoft Word documen

t using only the information contained within the changed rows (see th

e sample output document below). BuildDoc uses a template file (buildD

oc.dot) that contains the address header, and some preformatted text.  

It then writes a table into the document that has a row for each modif

ied row from the Web page form.  



How To Do It  
We start by reading all of the Web page form fields into hidden form f

ields on the receiving Web page. In the source code below, note the "  

onLoad " call in the body tag. It calls the buildDoc VBScript subrouti

ne, passing three parameters to it: the contents of the page''s form (a

ll the hidden fields), the location of the Word template file, and the

number of rows received from the input form. The input form fields ar

e all read and then, when the page loads, it calls the buildDoc subrou

tine. For the sake of brevity, we will assume that all variables have  

been first declared before use.  

The code for the loading of the input form fields into buildDoc.asp is

thus: -  

<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//EN">  
<HEAD>  
<TITLE>Build Document</TITLE>  
<META HTTP-EQUIV="Refresh" CONTENT="30;URL=''orderForm.asp''">  
</HEAD>  
<%
dotLocation="''\\servername\directory\theTemplate.dot''"
intRowCount = Request.Form("rowCount") ''initialize a row counter
%>  
<BODY Language="VBScript" onLoad="buildDoc document.theForm,
<%=dotLocation%>,intRowCount>  
<FORM NAME="theForm">  
<%
itemCount = 0 ''set field counter to zero
For Each Item in Request.Form ''count up

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号