Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.net Excel versions

Posted on 2011-03-13
2
Medium Priority
?
334 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 2000 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:Murray Brown
ID: 35122024
Thanks for the help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

715 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