日期:2014-05-17  浏览次数:21299 次

谁能帮我解决了这个问题,我给他磕十个响头并送100分,一辈子感激他!!!
一个问题:
    将ACCESS数据库的查询结果表导到WORD中, <table   id= "data "> ,然后用下面的脚本执行导到word,但是在WORD中只显示查询结果表的第一行第一列一个单元格,其他单元格并不显示数据记录,请朋友们帮忙看看下面哪个地方错了!在下感激不尽!
<script   language= "vbscript ">
dim   table1,row,wdapp,wddoc,column,i,j,rngpara,rngcurrent,tabcurent
set   table1=document.all.data
row=table1.rows.length
set   wdapp=createobject( "word.application ")
wdapp.visible=true
set   wddoc=wdapp.documents.add
column=table1.rows(1).cells.length
reDim   theArray(column,row)
for   i=0   to   row-1
    for   j=0   to   column-1
        theArray(j+1,i+1)=table1.rows(i).cells(j).innerHTML
      next
next
intNumrows=row
wdapp.application.activedocument.paragraphs.add.range.insertbefore( "销毁登记表 ")
set   rngpara=wdapp.application.activedocument.paragraphs.add.range
with   rngpara
.paragraphformat.alignment=1
.font.name= "arial "
.font.size=9
end   with
set   rngPara=wdapp.Application.ActiveDocument.Paragraphs(1).Range
with   rngPara
.bold=true
.ParagraphFormat.Alignment=1
.font.name= "arial "
.font.size=12
end   with
set   rngcurrent=wdapp.application.activedocument.paragraphs(3).range
set   tabcurent=wdapp.application.activedocument.tables.add(rngcurrent,intnumrows,column)
for   i=1   to   row
for   j=1   to   column
wdapp.application.activedocument.tables(1).rows(i).cells(j).range.InsertAfter   theArray(j,i)
wdapp.application.activedocument.tables(1).rows(i).cells(j).range.paragrapFormat.alignment=1
next
next
wdapp.application.activedocument.SaveAs   "newdoc.doc "
</script>



------解决方案--------------------
哇这么严重..

我说的是你的标题

你先把输出结果输出到普通的HTML看看正常否

正常后 再写到WORD
------解决方案--------------------
没做过这样的实现
我的想法是先写到一个文件中(譬如写成csv文件先),然后再调word的宏,让vba写数据
------解决方案--------------------
参考一下excel的
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 无标题文档 </title>
</head>

<body>
<TABLE id= "outtable " name= "outtable ">
<TR>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
</TR>
<TR>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
</TR>
<TR>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
</TR>
<TR>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>
<TD> asdf </TD>