vb asp.net open excel file exception

144 Views Asked by At

Please I have a problem with vb.net opening excel file.

I have just one excel file work properly, but when I try with any other excel files the app gives me this exception.

my code is correct but I think that I missed something somewhere.

this is my code:

Imports Microsoft.Office.Interop
Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office

Dim app As Excel.Application
Public EXCEL_CLASSEUR As Excel.Workbook = Nothing
Dim EXCEL_CLASSEUR_Workbooks As Excel.Workbooks = Nothing

Protected Sub BTN_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BTN.Click


If (FileUpload1.HasFile) Then

    app = New Excel.Application 'Lance une copie invisible d’Excel 
    EXCEL_CLASSEUR = app.Workbooks.Open(FileUpload1.PostedFile.FileName)
End If
EndSub

Thank you for your help

0

There are 0 best solutions below