How to overwrite an excel application without prompting the users

后端 未结 4 1622
甜味超标
甜味超标 2021-01-19 14:13

Can anyone help me on how can I overwrite the excel file without prompting the users in VB.Net..

I have try this code but It doesn\'t work..

Dim xlsA         


        
4条回答
  •  野的像风
    2021-01-19 14:41

    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
    

提交回复
热议问题