任何人都可以帮助我如何在不提示VB.Net中的用户的情况下覆盖excel文件. 我试过这段代码,但它不起作用.. Dim xlsApp As New Excel.ApplicationDim xlsBook As Excel.WorkbookDim xlsSheet As Excel.WorksheetDim dir
          我试过这段代码,但它不起作用..
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
        
             