Baze de date
Comunicarea cu EXCELComunicarea cu EXCELMODELUL OBJECT EXCEL Extras din modelul Object Excel ( Collections si Object).
OBIECTELE SI COLECTIILE EXCEL
COLECTIA WORKBOOKS Se compune din:
OBIECTELE WORKBOOKUn obiect Workbook permite crearea unei referinte la o clasa Excel. Proprietatea Active Workbook desemneaza o clasa activa.
SCRIEREA DATELOR IN CELULELE EXCEL
Private Sub ExportXLS_Client() `Obiecte Access Dim dbsGabi as DAO.database Dim stClient As DAO.RecordSet Dim fld As DAO.Field `Obiecte Excel Dim appExcel As Excel.application Dim wkbClient As Excel.Workbook Dim wksClient As Excel.Woorksheet `Variabile ciclice Dim intLig As Integer Dim intCol As Integer ` crearea unei mape Excel Set appExcel = CreateObject(„Excel.Application”) Set wkbclient = appExcel.Workbook.Add Set wksClient = appExcel.ActiveSheet appExcel.Visible = True `Deschiderea tabelului Clienti Set dbsGabi = DbEngine.OpenDatabase(„C:gabigabi1.mdb”) Set rstClient = dbsOpenRecordSet(„Clienti”, dbOpenDynaset) `Actualizarea unei foi active With wksClient `Antetele coloanelor completate de numele campurilor intCol = 1 For Each fld In rstClient.Fields .Cells(1,intCol).Value = fld.Name intCol =IintCol + 1 Next fld `Parcurgerea inregistrarilor `Adaugarea unei linii pentru fiecare inregistrare intLig = 2 Do While Not rstClient.Fields Intcol =1 For Each fld In rstClient.Fields .Cells(intLig, intCol).Value = fld.Value intCol = intCol + 1 Next fld intLig = intLig +1 rstClient.MoveNext Loop `Atribuirea unui nume foii Excel .Name = „lista de clienti” End With `Inregistrarea mapei de lucru wkbClient.SaveAs „C:ClientiClienti.xls” `Inchide Excel appExcel.Quit End Sub
|