en Ejemplos, Harbour

Ejemplo ADOxls (adoxls.prg)

/*
 *
 * http://support.microsoft.com/kb/257819
 *
 * 2010 Adapted by MigSoft <mig2soft / at / yahoo.com>
 * www – http://mig2soft.com
 *
 */

#include "ado.ch"

Function Main()
   
Local cn,rsT,strTbl,rsC

    With Object cn := CreateObject( "ADODB.Connection" )
   
:Provider="Microsoft.Jet.OLEDB.4.0"
   
:ConnectionString="Data Source=ExcelSrc.xls;Extended Properties=Excel 8.0;"
   
:Provider="MSDASQL"
   
:ConnectionString="Driver={Microsoft Excel Driver (*.xls)};DBQ=ExcelSrc.xls;"
   
:CursorLocation=adUseClient
   
:Open()
   
End

    rsT := cn:OpenSchema(adSchemaTables)
   
intTblCnt := rsT:RecordCount
   
intTblFlds := rsT:Fields:Count
   
? "Tables: " , str( intTblCnt)
   
? "——————–"
   
For t := 1 To intTblCnt
   
strTbl := rsT:Fields("TABLE_NAME"):Value
   
? "Table # " +ltrim(str( t ))+ ‘ ‘ + strTbl
   
? "——————–"
   
For f := 0 To intTblFlds  1
           
? rsT:Fields(f):Name
           
? rsT:Fields(f):Value
   
Next
   
?  "——————–"
   
rsC := cn:OpenSchema(adSchemaColumns, {,,strTbl,} )
   
intColCnt := rsC:RecordCount
   
intColFlds := rsC:Fields:Count
   
For c := 1 To intColCnt
       
strCol := hb_ansitooem(rsC:Fields("COLUMN_NAME"):Value)
       
? "Column #: " + ltrim(str(c)) + ‘ ‘ + strCol
       
? "——————–"
           
For f := 0 To intColFlds  1
               
? rsC:Fields(f):Name
                   
? rsC:Fields(f):Value
       
Next
       
? "——————–"
       
rsC:MoveNext()
       
wait
   
Next
   
rsC:Close()
   
? "——————–"
   
rsT:MoveNext()
   
Next
   
rsT:Close()
   
cn:Close()

Return( Nil )