Solved

ASP.net Excel versions

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

624 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