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 ap As Excel.Application
Dim classeur As Excel.Workbook
Dim feuille As Excel.Worksheet
Dim Plage As Object
Dim i As Int16, j As Int16
ap = CreateObject("Excel.Application")
classeur = ap.Workbooks.Add
feuille = classeur.Worksheets(1)
feuille.Cells(1, 1) = "Ville"
feuille.Cells(1, 2) = CStr(ComboBox1.Text)
feuille.Cells(2, 1) = "Latitude"
feuille.Cells(2, 2) = CStr(TextBox11.Text)
feuille.Cells(3, 1) = "Longitude"
feuille.Cells(3, 2) = CStr(TextBox11.Text)
feuille.Cells(2, 5) = "Altitude"
feuille.Cells(2, 6) = CStr(TextBox33.Text)
feuille.Cells(3, 5) = "Température ambiante"
feuille.Cells(3, 6) = CStr(TextBox34.Text)
feuille.Cells(2, 9) = "Humidité Relative"
feuille.Cells(2, 10) = CStr(TextBox35.Text)
With feuille
Plage = .Range(.Cells(6, 1), .Cells(DataGridView1.Rows.Count + 1, DataGridView1.Columns.Count))
End With
For i = 0 To DataGridView1.Columns.Count - 1
feuille.Cells(5, i + 1) = DataGridView1.Columns(i).HeaderText
feuille.Cells(5, i + 1).Font.Bold = True
feuille.Cells(5, i + 1).HorizontalAlignment = -4108
feuille.Cells(5, i + 1).VerticalAlignment = -4108
Next
For i = 0 To DataGridView1.RowCount - 2
For j = 0 To DataGridView1.ColumnCount - 1
Plage(i + 1, j + 1) = DataGridView1(j, i).Value
Next
Next
classeur.SaveAs("C:\Users\SONY\Desktop\ concentrateursolaire.xls")
MessageBox.Show("Enregistrement effectué, voir fichier concentrateursolaire dans le bureau")
classeur.Save()
classeur.Close()
ap.Quit() |
Partager