欢迎光临
我们一直在努力

调用Word打印…-ASP教程,打印相关

建站超值云服务器,限时71元/月

调用word打印…

运行下列的脚本需要将ie的安全级别设为低,或在中级安全级别下将那个activex控件设为启用,别忘记了:

<html>

<head>

<title>build document by script</title>

</head>

<table id="mydata" border=1 align=center>

<tr align=center>

<td>产品名称</td>

<td>产品描述</td>

<td>产品单价</td>

<td>产品等级</td>

</tr>

<tr align=center>

<td>产品一</td>

<td>this is a test</td>

<td align=right>300.50</td>

<td>一级</td>

</tr>

<tr align=center>

<td>产品二</td>

<td>this is a test</td>

<td align=right>300.50</td>

<td>一级</td>

</tr>

<tr align=center>

<td>产品三</td>

<td>this is a test</td>

<td align=right>300.50</td>

<td>一级</td>

</tr>

</tabld>

<input type=button onclick="vbscript:builddoc ,4" value="build">

<body>

</body>

</html>

<script language="vbscript">

sub builddoc(thetemplate,inttablerows)

dim table1

set table1 = document.all.mydata

row = table1.rows.length

set objworddoc = createobject("word.document")

objworddoc.application.visible=true

dim thearray(4,4)

redim preserve thearray(4,row)

colnum = table1.rows(1).cells.length

for i=0 to row-1

for j=0 to colnum-1

thearray(j+1,i+1) = table1.rows(i).cells(j).innerhtml

next

next

intnumrows = 4

objworddoc.application.activedocument.paragraphs.add.range.insertbefore("测试的表格")

objworddoc.application.activedocument.paragraphs.add.range.insertbefore("")

objworddoc.application.activedocument.paragraphs.add.range.insertbefore("")

set rngpara = objworddoc.application.activedocument.paragraphs(1).range

with rngpara

.bold = true

.paragraphformat.alignment = 1

.font.name = "arial"

.font.size = 12

end with

set rngcurrent = objworddoc.application.activedocument.paragraphs(3).range

set tabcurrent = objworddoc.application.activedocument.tables.add(rngcurrent,intnumrows,4)

for i = 1 to colnum

objworddoc.application.activedocument.tables(1).rows(1).cells(i).range.insertafter thearray(i,1)

objworddoc.application.activedocument.tables(1).rows(1).cells(i).range.paragraphformat.alignment=1

next

tabrow = 2

for j = 2 to intnumrows

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(1).range.paragraphformat.alignment=1

objworddoc.application.activedocument.tables(1).rows(tabrow).cells(2).range.insertafter thearray(2,j)

objworddoc.application.activedocument.tables(1).rows(tabrow).cells(2).range.paragraphformat.alignment=1

objworddoc.application.activedocument.tables(1).rows(tabrow).cells(3).range.insertafter formatcurrency(thearray(3,j))

objworddoc.application.activedocument.tables(1).rows(tabrow).cells(3).range.paragraphformat.alignment=2

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.application.activedocument.tables(1).rows(tabrow).cells(4).range.paragraphformat.alignment=1

tabrow = tabrow + 1

next

objworddoc.application.activedocument.tables(1).rows(tabrow).cells(4).range.paragraphformat.alignment=1

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")

objworddoc.application.activedocument.envelope.insert address

objworddoc.application.activedocument.paragraphs.add.range.insertafter("由廖家远设计")

objworddoc.application.activedocument.saveas "tempsample.doc", 0,false,"",true,"",false,false,false, false,false

objworddoc.application.printout()

end sub

</script>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 调用Word打印…-ASP教程,打印相关
分享到: 更多 (0)