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

用ASP创建Word文件

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/17
下载{$ArticleTitle}原创论文样式
rice"                        intArrayY=2  
         Case "quantity"                     intArrayY=3  
      End Select  
      IntArrayX = strRight  
      If strOkay <> "N" Then  
         TheArray(intArrayY, intArrayX) = strValue  
      End If  
   End If  
Next  
%>  
Now we are ready to begin creating the document. We start by setting t

he Microsoft Word Document object RANGE using our variable, rngCurrent

, to the active document (just in case the user has a different docum

ent also open). Then we specify the table size by specifying its locat

ion ( rngCurrent ) and the number of rows and columns it needs.  

<%
Set rngCurrent = objWordDoc.Application.ActiveDocument.Content
Set tabCurrent = ObjWordDoc.Application.ActiveDocument.Tables.Add
rngCurrent,intNumrows,4)
%>  
Having created the document with the table, we now begin populating th

e table with data. First we point to the first row ( tabRow=1 ), then  

begin a loop that will run through each row. We insert a line feed [ C

hr(10) ] at the end of each row to put some white space between rows.  

Finally, we increment our row counter, output the dollar values with "

FormatCurrency" to ensure use of dollar signs, commas and decimal plac

es. Right justification of dollar amounts is handled by setting the co

lumn in question to " ParagraphAlignment=2 ". I won''t tell you how muc

h of a pain it was to discover how to do that! Suffice it to say that  

it is easier and better documented in VBA, which is not at all like wh

at is required in VBScript.  

<%
For j = 1 to intTableRows

ObjWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Borders.E

nable=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))

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

tabRow = tabRow + 1

Next
%>  
Finally, we finish up our docu

网学推荐

免费论文

原创论文

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