您现在的位置是:网站首页> 编程资料编程资料

如何创建Word文件?_编程10000问_

2023-05-25 168人已围观

简介 如何创建Word文件?_编程10000问_

creatdoc.asp



</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">星河影动之创建</span><span lang="EN-US">Word</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件</span><span lang="EN-US">


<%
    dotLocation="'servernamedirectory    heTemplate.dot'"
    intRowCount = Request.Form("rowCount") 

' 初始化行计数.
%>

-----------------------------------------------------------------------------------------------------------------------------------

body标记中对onLoad调用,调用creatdoc VB脚本子程序,向它传递3个参数:页面中表单的内容(所有的隐含域)、Word模板文件的位置、从输入表单中收到的行数.读所有的输入表单域,然后当页面装载后调用creatdoc子程序
<%
    itemCount = 0                           

' 设置域计数器为0.
    For Each Item in Request.Form           

' 总计表格域.
    itemCount = itemCount + 1           

' 使用For..Next 循环.

%>
   
<% Next %>
   
   


-------------------------------------------------------------------------------------------------------------------------------------
  

开始创建一个Word 文件对象. Internet Explorer 4以上版本中,要将浏览器的安全性设置为Low Custom
<%
Set objWordDoc = CreateObject("Word.Document")
ObjWordDoc.Application.Documents.Add theTemplate, False
ObjWordDoc.Application.Visible=True
%>
-------------------------------------------------------------------------------------------------------------------------------------

调整数组的维数使它与网页表单所包含的行数相同.Y轴设为4个常量,这是输出文件中所需要的栏数,X轴包含从表单中接收的行数
<% Redim Preserve theArray(4,intTableRows) %>
-------------------------------------------------------------------------------------------------------------------------------------

开始检查所有的表单行.在所有输入的网页表单域中循环,收集每个表单域名及其相应的值.逐个检查并将其放入相应的数列元素内.在此,我们使用了不确定编码的CASE选择
<%
For intCount = 0 to frmData.fieldCount.value
  strOkay = "Y"
  strSearch = frmData.elements(intCount).name 

' 装入表单域名.
  strValue = frmData.elements(intCount).value 

' 装入表单域值.
  strPosition = Instr(1,strSearch,"_")         

intStringLen=strPosition-1
  If intStrLen > 0 Then
      strLeft = Left(strSearch,intStringLen)
      strRight = Right(strSearch,(Len(strSe

-六神源码网