Solved

ASP.net Excel versions

Posted on 2011-03-13
2
330 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
ID: 35120855
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
ID: 35122024
Thanks for the help
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

837 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