各位楼主能发个列子吗?这是小弟写的。但是 不 能操作。请 楼主指点。谢谢。。
Imports excel = Microsoft.Office.Interop.Excel
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim fileTest As String = "c:\Temp\ExcelTest\test.xlsx"
If File.Exists(fileTest) Then
File.Delete(fileTest)
End If
Dim oexcel As Object
oexcel = CreateObject("excel.Application")
Dim obook As excel.Workbook
Dim osheet As excel.Worksheet
obook = oexcel.Workbooks.Add
osheet = oexcel.Worksheets(1)
osheet.Name = "test name"
osheet.Range("1,1").Value = "button 1"
obook.SaveAs(fileTest)
obook.Close()
obook = Nothing
oexcel.Quit()
oexcel = Nothing
End Sub
End Class