trucss
Messages postés189Date d'inscriptionjeudi 17 février 2022StatutMembreDernière intervention23 janvier 2024
-
18 juil. 2023 à 10:07
Whismeril
Messages postés19030Date d'inscriptionmardi 11 mars 2003StatutContributeurDernière intervention27 avril 2024
-
18 juil. 2023 à 20:32
Bonjour,
J'exporte les données d'une listview vers Excel ça fonctionne mais j'ai des erreurs quand je régénère la solution c'est aléatoire.
Public Sub subExporterExcel(ByVal lvw As ListView)
Try
Dim xla As New Microsoft.Office.Interop.Excel.Application()
xla.Visible = True
Dim wb As Microsoft.Office.Interop.Excel.Workbook = xla.Workbooks.Add(Microsoft.Office.Interop.Excel.XlSheetType.xlWorksheet)
Dim ws As Microsoft.Office.Interop.Excel.Worksheet = DirectCast(xla.ActiveSheet, Microsoft.Office.Interop.Excel.Worksheet)
Dim ligne As Integer = 1
Dim colonne As Integer = 1
Dim jj As Integer = lvw.Columns.Count
For rr = 0 To lvw.Columns.Count - 1
ws.Cells(ligne, colonne) = lvw.Columns(rr).Text
colonne = colonne + 1
Next
ligne = 2
colonne = 1
For Each comp As ListViewItem In lvw.Items
ws.Cells(ligne, colonne) = comp.Text.ToString()
For Each drv As ListViewItem.ListViewSubItem In comp.SubItems
ws.Cells(ligne, colonne) = drv.Text.ToString()
colonne += 1
ws.Columns.AutoFit()
Next
colonne = 1
ligne += 1
Next
Catch ex As Exception
End Try
End Sub