<script language="vbscript">

'======================================================='
 sub  printer() 'RDS1GRID1Ĵӡ
'=======================================================

    if grid1.row<0 then
     
     exit  sub
     
    end if  
               
    Set xlApp = CreateObject("Excel.Application") 
 
    xlApp.Visible = True 
 
    Set xlBook = xlApp.Workbooks.Add
    
    Set xlSheet = xlBook.Worksheets(1)
 
   
   rds1.Recordset.movefirst
   
   grid1.row=0
   
   midadd= int(grid1.columns.count/2)+1 
   
   xlSheet.Cells(2, midadd) = titlename
   
   
   for j=0 to grid1.columns.count-1
   
    
      xlsheet.cells(4,j+1)=grid1.columns.item(j).caption
         
   
   next
        
        
   for i=0 to rds1.Recordset.recordcount-1
    
     for  k=0 to grid1.columns.count-1
            
       If isnull(grid1.columns.item(k))=false  then  
                              
          if IsNumeric(grid1.columns.item(k)) = true  Then        
        
                       
                  xlsheet.cells(i+5,k+1)=trim(cstr(grid1.columns.item(k)))
          else
                  xlsheet.cells(i+5,k+1)=grid1.columns.item(k)
        
         end if
   
      end if   
     
     next 
  
     grid1.row=grid1.row+1

    next 

end sub


'======================================================='
 sub  free_printer(maxcount,headtitle) 'ֻGRID1Ĵӡ
'=======================================================

    if grid1.row<0 then
     
     exit  sub
     
    end if  
               
    Set xlApp = CreateObject("Excel.Application") 
 
    xlApp.Visible = True 
 
    Set xlBook = xlApp.Workbooks.Add
    
    Set xlSheet = xlBook.Worksheets(1)
 
      
    grid1.row=0
  
	midadd = int(grid1.columns.count/2)+1   
    xlSheet.Cells(2, midadd) = headtitle
   
    for j=0 to grid1.columns.count-1
   
    
      xlsheet.cells(4,j+1)=grid1.columns.item(j).caption
         
   
   next
        
        
   for i=0 to maxcount-1
    
     for  k=0 to grid1.columns.count-1
            
       If isnull(grid1.columns.item(k))=false  then  
                              
          if IsNumeric(grid1.columns.item(k)) = true  Then        
                  xlsheet.cells(i+5,k+1)=trim(cstr(grid1.columns.item(k)))
                            
          else
                  xlsheet.cells(i+5,k+1)=grid1.columns.item(k)
         end if
     
      end if   
     
     next 
       
     grid1.row=grid1.row+1

    next 

end sub

</script>