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
| Imports Microsoft.Office.Interop
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim AppExcel As Excel.Application = New Excel.Application
AppExcel.SheetsInNewWorkbook = 6
Dim xlBook As Excel.Workbook = AppExcel.Workbooks.Add()
Dim xlSheet As Excel.Worksheet = CType(xlBook.Sheets(5), Excel.Worksheet)
xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(10, 1)).FormulaLocal = "=Ligne()"
xlSheet.Range(xlSheet.Cells(1, 2), xlSheet.Cells(10, 2)).FormulaLocal = "=Ligne()*colonne()"
Dim xlRange As Excel.Range
xlRange = xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(10, 2))
Dim xlCharts As Excel.ChartObjects
Dim xlChart As Excel.ChartObject
xlCharts = CType(xlSheet.ChartObjects, Excel.ChartObjects)
xlChart = xlCharts.Add(20.0F, 20.0F, 300.0F, 300.0F)
With xlChart.Chart
.ChartType = Excel.XlChartType.xlColumnClustered
.SetSourceData(xlRange)
.HasTitle = True
.ChartTitle.Characters.Text = "UN GRAPHIQUE"
.HasLegend = False
.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowValue, False)
End With
AppExcel.Visible = True
End Sub
End Class |
Partager