wawiarawia
Messages postés4Date d'inscriptiondimanche 18 avril 2010StatutMembreDernière intervention 3 mai 2011
-
12 mai 2010 à 18:24
dev74100
Messages postés1Date d'inscriptionmardi 27 avril 2010StatutMembreDernière intervention22 mars 2011
-
22 mars 2011 à 13:12
jé prépare mon PFE avec vb.net et access j'ai une problème je veux exporter le contenu d'un datagrid vers excel mai je n'arrive pas . svp est ce qu'il ya kelk1 ki peu m'aider . c'est urgenttttttttt
merciiiiiiiiiiii d'avence
dev74100
Messages postés1Date d'inscriptionmardi 27 avril 2010StatutMembreDernière intervention22 mars 2011 22 mars 2011 à 13:12
Private Sub bt_excel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_excel.Click
Dim rowsTotal, colsTotal As Short
Dim I, j, iC As Short
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Try
Dim excelBook As Microsoft.Office.Interop.Excel.Workbook = xlApp.Workbooks.Add
Dim excelWorksheet As Microsoft.Office.Interop.Excel.Worksheet = CType(excelBook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
xlApp.Visible = True
rowsTotal = DataGridView1.RowCount - 1
colsTotal = DataGridView1.Columns.Count - 1
With excelWorksheet
.Cells.Select()
.Cells.Delete()
For iC = 0 To colsTotal
.Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
Next
For I = 0 To rowsTotal
For j = 0 To colsTotal
.Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value
Next j
Next I