Object Library . " Klik op "OK . "
Dubbelklik op " Button " 3 op de " Tools" venster naar een nieuwe knop controle te voegen " Form1 . " . Dubbelklik op " Button1 " om de " Form1.vb " module te openen
Type 4 de volgende in de eerste regel van uw module :
Imports Microsoft.Office.Interop
5
Typ het volgende onder " Button1_Click " om uw Excel- object-variabelen definiëren :
Dim XLSApp als Nieuwe Excel.Application
XLSApp.Visible = True < br
Dim XLSWbks > Zoals Excel.Workbooks = XLSApp.Workbooks
Dim XLSWbk
Zoals Excel.Workbook = XLSWbks.Add
Dim XLSShts Zoals Excel.Sheets = XLSWbk.Worksheets
Dim XLSSht Zoals Excel.Worksheet = XLSShts ( " Blad1 " ) op Twitter
Type 6 de volgende tekst toe te voegen aan uw nieuwe Excel-werkblad :
XLSSht.Range
( " A1 " . ) Value = " Deze code werd toegevoegd met behulp van het Excel Object Model in VB.NET "
Type 7 het volgende toe aan uw werkmap op te slaan :
XLSSht.SaveAs
( " G : \\ my2007ExcelWorkbook.xlsx " )
Pers Nieuws" F5 "om uw programma uit te voeren , en klik op" Button1 " naar een Microsoft Office Excel- werkmap te maken .