cetee
級別: 略有小成
|
希望各位大俠幫幫忙。 vb如何把文本框中的數據保存到excel,不能覆蓋,而是能保存到下一行,不影響前幾行保存的數據. |
---|---|
|
cetee
級別: 略有小成
|
各位樓主能發個列子嗎?這是小弟寫的。但是 不 能操作。請 樓主指點。謝謝。。 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 |
---|---|
|