comment ecrire dans un fichier excel
je dois lire et ecrire des donnees dans un fichier excel
j arrive a les lires
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Dim DS As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim lRetour(0, 0) As Object
Dim lStr As String
Try
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & "data source=" & pPath & "; " & "Extended Properties=Excel 8.0;")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" & pSheetName & "$]", MyConnection)
DS = New System.Data.DataSet
MyCommand.Fill(DS)
Dim lFeuilleExcel As System.Data.DataTable
lFeuilleExcel = DS.Tables(0)
Dim lLigneExcel As DataRow
Dim lCompteur As Long = 0
Dim lNB_Ligne As Long
Dim lNB_Colonne As Long
lNB_Ligne = lFeuilleExcel.Rows.Count
lNB_Colonne = lFeuilleExcel.Rows(0).ItemArray.GetUpperBound(0)
ReDim lRetour(lNB_Ligne - 1, lNB_Colonne)
For Each lLigneExcel In lFeuilleExcel.Rows
Dim lArray() As Object
lArray = lLigneExcel.ItemArray
For i As Long = 0 To lArray.GetUpperBound(0)
lStr = ""
If IsDBNull(lArray(i)) = True Then
lStr = ""
Else
lStr = lArray(i)
End If
lRetour(lCompteur, i) = lStr
Next
lCompteur += 1
Next |
mais comment sauvegarder lorsque je fais des modifications
merci