无为清净楼资源网 Design By www.qnjia.com

creatdoc.asp

<!DOCTYPE html PUBLIC "-//W3C/Dtd html 3.2 Final//EN">
<head>
<title>星河影动之创建Word文件</title>
<META HTTP-EQUIV="Refresh" CONTENT="30;URL='orderForm.asp'">
</head>
<%
    dotLocation="'servernamedirectory    heTemplate.dot'"
    intRowCount = Request.Form("rowCount") 

' 初始化行计数.
%>
<body Language="VBScript" onLoad="creatdoc document.theForm,
<%=dotLocation%>,intRowCount>
<FORM NAME="theForm">

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

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

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

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

' 使用For..Next 循环.

%>
    <INPUT TYPE="hidden" NAME="<%=Item%>" VALUE="<%=Request(Item)%>">
<% Next %>
    <INPUT TYPE="hidden" NAME="numbRows"  VALUE="<%=intRowCount%>">
    <INPUT TYPE="hidden" NAME="fieldCount" VALUE="<%=itemCount%>">
</FORM>
</body></html>
-------------------------------------------------------------------------------------------------------------------------------------  

开始创建一个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(strSearch)-Len(strLeft)-1))
      Select Case strLeft

' Select Case命令决定表单域属于哪一列.
        Case "SKU"                       intArrayY=0
        Case "description"                 intArrayY=1
        Case "price"                       intArrayY=2
        Case "quantity"                    intArrayY=3
      End Select
      IntArrayX = strRight
      If strOkay <> "N" Then
        TheArray(intArrayY, intArrayX) = strValue
      End If
  End If
Next
%>

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

开始创建文件
<%
    Set rngCurrent = objWordDoc.Application.ActiveDocument.Content

' 对于激活的文件,用变量rngCurrent设置Word文件对象RANGE,这是为了防止用户打开另一个文件.
    Set tabCurrent =  ObjWordDoc.Application.ActiveDocument.Tables.Add
    rngCurrent,intNumrows,4)

   ' 通过指定表格的位置( rngCurrent)以及行、列的数目来确定其大小.

%>

------------------------------------------------------------------------------------------------------------------------------------  
向往表格里装入数据.

<%
For j = 1 to intTableRows
 ' 首先指到第一行row(tabRow=1), 逐行循环.在每行结尾处插入回车[Chr(10)],以产生行间空行,使行计数器增加.
ObjWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Borders.Enable=False

objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(1).Range.InsertAfter
    theArray(1,j)

objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(2).Range.InsertAfter
    theArray(2,j)

objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).Range.InsertAfter
    FormatCurrency(theArray(3,j))
    ' 用FormatCurrency 输出美圆值以保证使用$符号,逗号,小数点的位置.

objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.InsertAfter
    theArray(4,j)

objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.InsertAfter
    Chr(10)

objWordDoc.Applicatoin.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).
    Range.ParagraphFormat.alignment=2
    ' 在ParagraphFormat. alignment=2处设置栏数来实现美圆数量的正确调整.

tabRow = tabRow + 1

Next
%>

------------------------------------------------------------------------------------------------------------------------------------
指定模板位置,结束子程序
<%
objWordDoc.Application.ActiveDocument.Paragraph.Add.Range.
    InsertAfter("Thank you for shopping at Acme Co., and please come again!")
objWordDoc.Application.ActiveDocument.Paragraph.Add.Range.InsertAfter(" ")
objWordDoc.Application.ActiveDocument.Paragraph.Add.Range.InsertAfter(" ")
objWordDoc.Application.ActiveDocument.Paragraph.Add.Range.InsertAfter("Regards,")
objWordDoc.Application.ActiveDocument.Paragraph.Add.Range.InsertAfter(" ")
objWordDoc.Application.ActiveDocument.Paragraph.Add.Range.
  InsertAfter("Daryl B. Morticum")
objWordDoc.Application.ActiveDocument.Paragraph.Add.Range.
  InsertAfter("Sales Associate")
End Sub
%>

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

 

 

 

标签:
|如何|何创|创建|建W|Wo|or|rd|d文|文件|件?|?|

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。

更新日志