<script   language="vbscript">   
  Sub   buildDoc   
  set   table   =   document.all.data12   
  row   =   table.rows.length   
  column   =   table.rows(1).cells.length   
    
  Set   objWordDoc   =   CreateObject("Word.Document")   
    
  ''objWordDoc.Application.Documents.Add   theTemplate,   False   
  objWordDoc.Application.Visible=True   
    
  Dim   theArray(20,10000)   
  for   i=0   to   row-1   
  for   j=0   to   column-1   
  theArray(j+1,i+1)   =   table.rows(i).cells(j).innerTEXT   
  next   
  next   
  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   =   "隶书"   //设定标题字体   
  .Font.Size   =   18   //设定标题字体大小   
  End   With   
  Set   rngCurrent   =   objWordDoc.Application.ActiveDocument.Paragraphs(3).Range   
  Set   tabCurrent   =   ObjWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent,row,column)   
    
  for   i   =   1   to   column     
    
  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   
  For   i   =1   to   column   
  For   j   =   2   to   row     
  objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter   theArray(i,j)     
  objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment=1   
  Next   
  Next   
    
  End   Sub   
  </script>无实体边框 打印的时候还需要加边框

解决方案 »

  1.   

    <script language="vbscript">    
      Sub buildDoc    
      set table = document.all.data12
      row =   table.rows.length
      column = table.rows(1).cells.length    
         
      Set objWordDoc = CreateObject("Word.Document")    
         
      ''objWordDoc.Application.Documents.Add   theTemplate,   False    
      objWordDoc.Application.Visible=True    
         
      Dim   theArray(20,10000)    
      for   i=0   to   row-1    
      for   j=0   to   column-1    
      theArray(j+1,i+1)   =   table.rows(i).cells(j).innerTEXT    
      next    
      next    
      objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("综合查询结果集")   //显示表格标题    
         objWordDoc.Application.ActiveDocument.Tables(1).Borders.InsideLineStyle = True 
    objWordDoc.Application.ActiveDocument.Tables(1).Borders.OutsideLineStyle = True 

      objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")    
      Set   rngPara   =   objWordDoc.Application.ActiveDocument.Paragraphs(1).Range    
      With   rngPara    
      .Bold   =   True   //将标题设为粗体    
      .ParagraphFormat.Alignment   =   1   //将标题居中    
      .Font.Name   =   "隶书"   //设定标题字体    
      .Font.Size   =   18   //设定标题字体大小    
      End With    
      Set rngCurrent = objWordDoc.Application.ActiveDocument.Paragraphs(3).Range    
      Set tabCurrent = ObjWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent,row,column)    
         
      for   i   =   1   to   column      
         
      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    
      For   i   =1   to   column    
      For   j   =   2   to   row      
      objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.InsertAfter   theArray(i,j)      
      objWordDoc.Application.ActiveDocument.Tables(1).Rows(j).Cells(i).Range.ParagraphFormat.alignment=1    
      Next    
      Next    
         
      End   Sub    
       </script> 
    拷贝回去后把不必要的空格删除一下.
      

  2.   


         objWordDoc.Application.ActiveDocument.Tables(1).Borders.InsideLineStyle = True 
    objWordDoc.Application.ActiveDocument.Tables(1).Borders.OutsideLineStyle = True 
    是不 就加了这两句
    提示网业有错误啊