Bonjour
Je n'arrive pas à exporter une image vers Excel en VB.net malgré mes nombreuses recherches et essais trouvés sur le net !!!
Voici mon code de base et soucis ligne 47:
Pouvez-vous m'aider à résoudre ce problème ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53 Dim ExcelApp As Object, ExcelBook As Object Dim ExcelSheet As Object Dim i As Integer Dim j As Integer ' Minimum à 1 ProgressBar1.Minimum = 0 ' Maximum= nombre total de fichier à copier. 'ProgressBar1 = filenames.Length ' On initialise la ProgressBar. ProgressBar1.Value = 1 ' On indique le pas. ProgressBar1.Step = 6 ProgressBar1.Style = ProgressBarStyle.Continuous ProgressBar1.Visible = True 'Export Excel ExcelApp = CreateObject("Excel.Application") ExcelBook = ExcelApp.WorkBooks.Add ExcelSheet = ExcelBook.WorkSheets(1) Dim c As Color Dim titre As String With ExcelSheet titre = nom & " " & prenom If numero <> "" Then titre = titre + " - N° Référant Pôle Emploi: " & numero ExcelSheet.Cells(1, 1).value = titre For Each col As DataGridViewColumn In Me.DataGridView1.Columns ExcelSheet.Cells(3, col.Index + 1).Font.Color = System.Drawing.ColorTranslator.ToOle(Color.White) ExcelSheet.Cells(3, col.Index + 1).Interior.Color = System.Drawing.ColorTranslator.ToOle(Color.Black) ExcelSheet.Cells(3, col.Index + 1) = col.HeaderText.ToString For i = 1 To Me.DataGridView1.RowCount - 1 ExcelSheet.cells(i + 3, 1) = Me.DataGridView1.Rows(i - 1).Cells("numero_offre").Value For j = 0 To DataGridView1.Columns.Count - 1 ExcelSheet.cells(i + 3, j + 1) = DataGridView1.Rows(i - 1).Cells(j).Value c = DataGridView1.Rows(i - 1).Cells(j).Style.BackColor Dim value As Integer = c.ToArgb() Dim hex As String = value.ToString("X6") If hex <> "000000" Then 'MessageBox.Show(MyColor.Name) ExcelSheet.Cells(i + 3, j + 1).Interior.Color = System.Drawing.ColorTranslator.ToOle(c) End If Next Next ExcelSheet.Cells.font.size = 8 '--------------------- Export image vers Excel ----------------------------------------------- ExcelSheet.Pictures.Add(i + 1 + 3, 1, "images\code_couleur_legende.jpg") ' <------------------ '--------------------------------------------------------------------------------------------- ExcelSheet.Cells(i + 1 + 12, 1).value = "© Copyright 2017 - DP - EMPLOI Suivi®" ExcelSheet.Cells(i + 1 + 13, 1).value = "Site EMPLOI Suivi : http://contact72.free.fr//sites/EMPLOI_Suivi/" ProgressBar1.PerformStep() Next End With
Merci à tous
Cordialement.
Partager