asp数据倒出到word模板,是否可放在client端做,以节省服务器开销?(200分)

X

xuyq

Unregistered / Unconfirmed
GUEST, unregistred user!
asp数据倒出到word,我先是这样做:
server端建word模板文件,asp调用该模板的宏,在宏里新建word文档并连数据库
将数据填入,保存文档在server上,提供联接供用户下载。
但考虑到这样占用server开销,万一word模板出错,错报在server上,会影响server,
是否可将模板下载到客户端,在客户端执行宏,但如何判断第一次下载模板,以后就不
下载,改过后再下载?
 
哥们你怎么实现的能不能发给一份,我原来想做来着但没实现。
谢谢
wdllove@sina.com
 
这是在客户端的例子,自己看吧!
<head>
<title>Builddo
cument 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 wApp
Set wApp = CreateObject("Word.Application")
If Err.number > 0 then
Alert "没法保存为Word文件,请正确安装Word97"
END IF
wApp.visible = True
wApp.Documents.add
wApp.Selection.TypeParagraph
wApp.Selection.Font.Bold = True
wApp.Selection.TypeText "test"
Dim Table1
set Table1 =do
cument.all.myData
'row = Table1.rows.length
'Set wApp = CreateObject("Word.Document")
'wApp.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
wApp.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("测试的表格")
wApp.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
wApp.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
Set rngPara = wApp.Application.ActiveDocument.Paragraphs(1).Range
With rngPara
.Bold = True
.ParagraphFormat.Alignment = 1
.Font.Name = "Arial"
.Font.Size = 12
End With
Set rngCurrent = wApp.Application.ActiveDocument.Paragraphs(3).Range
Set tabCurrent = wApp.Application.ActiveDocument.Tables.Add(rngCurrent,intNumrows,4)
for i = 1 to colnum
wApp.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.InsertAfter theArray(i,1)
wApp.Application.ActiveDocument.Tables(1).Rows(1).Cells(i).Range.ParagraphFormat.alignment=1
next
tabRow = 2
For j = 2 to intNumrows
'wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Borders.Enable=False
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(1).Range.InsertAfter theArray(1,j)
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(1).Range.ParagraphFormat.alignment=1
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(2).Range.InsertAfter theArray(2,j)
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(2).Range.ParagraphFormat.alignment=1
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).Range.InsertAfter FormatCurrency(theArray(3,j))
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).Range.ParagraphFormat.alignment=2
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.InsertAfter theArray(4,j)
'wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.InsertAfter Chr(10)
wApp.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).Range.ParagraphFormat.alignment=1
tabRow = tabRow + 1
Next

End Sub
</script>
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部