Sui riferimenti aggiungere "Microsoft Excel 16.0 Object Library"
codice
Public Class Form1
Dim oExcel As Microsoft.Office.Interop.Excel.Application
Dim oBook As Microsoft.Office.Interop.Excel.Workbook
Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim raXL As Microsoft.Office.Interop.Excel.Range
Private Sub BtnApriExcel_Click(sender As Object, e As EventArgs) Handles BtnApriExcel.Click
' Start Excel and get Application object.
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
' open a workbook.
oBook = oExcel.Workbooks.Open("D:\DiscoD\pgmVS\Gru_pcs_2_D13\elencoPCSD13.xlsx")
oSheet = oBook.ActiveSheet
' Start Excel and get Application object.
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
' Add a new workbook.
oBook = oExcel.Workbooks.Add
oSheet = oBook.ActiveSheet
' Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "testo"
' Format A1:D1 as bold, vertical alignment = center.
oSheet.Range("A1", "I1").Font.Bold = True
End Sub
End Class
Nessun commento:
Posta un commento