Solved

ASP.net Excel versions

Posted on 2011-03-13
2
327 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:murbro
2 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
Comment Utility
murbro: I haven't worked with ASP.Net but In VB.Net what I do is I set a reference to the Microsoft Interop assemblies. Also to save as .xlsx or .xlsm, simply change the extension from .xls to .xlsx or .xlsm

Sid
0
 

Author Closing Comment

by:murbro
Comment Utility
Thanks for the help
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now