Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net Excel versions

Hi

The following code works with .xls (or 2003 and older file). How do I upgrade it to work with .xlsm and .xlsx  files too?
Protected Sub ButtonUploadFile_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
      Handles ButtonUploadFile.Click

      If FileUploadExcel.HasFile Then
         Try
            ' alter path for your project
            FileUploadExcel.SaveAs(Server.MapPath("~/ExcelImport.xls"))
            LabelUpload.Text="Upload File Name: " & _
                FileUploadExcel.PostedFile.FileName & "<br>" & _
                "Type: " & _
                FileUploadExcel.PostedFile.ContentType & _
                " File Size: " & _
                FileUploadExcel.PostedFile.ContentLength & " kb<br>"
         Catch ex As Exception
            LabelUpload.Text="Error: " & ex.Message.ToString
         End Try
      Else
         LabelUpload.Text="Please select a file to upload."
      End If

   End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks for the help