任何人都可以帮助我如何在不提示 VB.Net 中的用户的情况下覆盖 Excel 文件..
我已经尝试过这段代码,但它不起作用..
Dim xlsApp As New Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Dim dir As String = Application.StartupPath & "\Template\SampleTemplate.xls"
xlsBook = GetObject(dir)
xlsSheet = xlsBook.Sheets("Per BPA Error Report")
xlsSheet.Range("C2:T2").Merge()
xlsApp.DisplayAlerts = False
xlsSheet.SaveAs(Application.StartupPath & "\Template\SampleTemplate.xls")
xlsBook = Nothing
xlsSheet = Nothing
xlsApp.Quit()
最佳答案
Public Sub WriteExcelFile(ByVal ExcelFilePath As String)
Dim excel As Application = New Application
Dim w As Workbook = excel.Workbooks.Open(ExcelFilePath)
Dim sheet As Worksheet = w.Sheets(1)
sheet.Cells(x + 1, 1) = 10
x = x + 1
excel.DisplayAlerts = False
w.Save()
w.Close()
End Sub
关于vb.net - 如何在不提示用户的情况下覆盖 Excel 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2831735/