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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| 'Insertion entête fichier excel
Private Sub beta_insertion_entete_excel(ByVal fileName As String, ByVal date_deb As String, ByVal date_fin As String)
'Objets nécessaire à la manipulation de fichier.
Dim appExcel As Excel.Application
Dim wbExcel As Excel.Workbook
Dim wsExcel As Excel.Worksheet
Dim exRange As Excel.Range
Dim celluleStyle As Excel.CellFormat
Dim i As Integer = 1
Dim j As Integer = 0
Dim cpt_colonne As Integer = 0
Dim contenu As String = "'"
Dim test As String = ""
Try
'Ouverture de l'application
appExcel = CreateObject("Excel.Application")
'Ouverture d'un fichier
wbExcel = appExcel.Workbooks.Open(fileName)
'Ouverture de la première feuille du classeur
wsExcel = wbExcel.ActiveSheet
appExcel.Visible = True
While contenu <> ""
cpt_colonne = cpt_colonne + 1
exRange = wsExcel.Cells(1, cpt_colonne)
contenu = exRange.Value
End While
While i <> cpt_colonne
exRange = wsExcel.Cells(1, i)
For j = 1 To 9
exRange.Insert(Excel.XlInsertShiftDirection.xlShiftDown)
Next
i = i + 1
End While
wsExcel.Cells(1, 1) = Date.Today
exRange = wsExcel.Range(wsExcel.Cells(3, 1), wsExcel.Cells(3, i))
exRange.Merge()
exRange = wsExcel.Cells(3, 1)
With exRange
.Value = "LISTE DES DEMANDES D'EXPEDITION SANS FACTURATION"
.Font.Size = 14
.Font.Name = "Georgia"
.Font.Bold = True
.HorizontalAlignment = -4108
End With
exRange = wsExcel.Cells(5, 1)
With exRange
.Value = "EN RETRAITS GRATUITS ET A ENVOYER PAR LA POSTE"
.Font.Size = 12
.Font.Name = "Georgia"
.Font.Bold = True
End With
exRange = wsExcel.Cells(6, 1)
With exRange
.Value = "BORDEREAU N°"
.Font.Size = 12
.Font.Bold = True
.Font.Color = RGB(0, 0, 255)
End With
exRange = wsExcel.Range(wsExcel.Cells(8, 1), wsExcel.Cells(8, i))
exRange.Merge()
With exRange
.Value = "LISTE DES OUVRAGES POUR LA PERIODE DU " & date_deb & " AU " & date_fin & " A ENVOYER"
.Font.Size = 12
.Font.Bold = True
.Font.Color = RGB(255, 0, 0)
.HorizontalAlignment = -4108
End With
Catch ex As COMException
MessageBox.Show(ex.ToString() + " Erreur Génération entête fichier excel")
Finally
wbExcel.Close(True)
wbExcel = Nothing
appExcel.Quit()
appExcel = Nothing
End Try
End Sub |
Partager