Solved

ASP.NET Reponse.Content help with selecting and uploading file

Posted on 2007-04-09
3
415 Views
Last Modified: 2007-12-19
Hi, I'm using asp.net and a gembox Excel DLL to read/write excel files. The writing aspect works well using the following code, which prompts the user where to save the file.

//ef is the ExcelFile object.

 Response.Clear();
 Response.ContentType = "application/vnd.ms-excel";
 Response.AddHeader("Content-Disposition", "attachment; filename=temp.xls");
 ef.SaveXls(Response.OutputStream);
 Response.End();

Now, I need to figure out how to read the file using the ef.LoadXls function. It works fine if I hardcode the file to the local machine, but how do I get it to prompt the user through the web interface and allow them to select/upload the file?

Thanks,

Terry


0
Comment
Question by:TerryBurger
[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
3 Comments
 
LVL 5

Accepted Solution

by:
asp_lha earned 500 total points
ID: 18879693
first, you need to prompt the user to upload a file (show some help)
then upload the file where the user selected to a temp. directory
and use the ef.LoadXls to load the file.

sample code for upload file
(come from http://www.asp.net/learn/dataaccess/tutorial54vb.aspx?tabid=63):

Protected Sub UploadButton_Click(sender As Object, e As EventArgs) _
    Handles UploadButton.Click
   
    If UploadTest.HasFile = False Then
        ' No file uploaded!
        UploadDetails.Text = "Please first select a file to upload..."
    Else
        ' Display the uploaded file's details
        UploadDetails.Text = String.Format( _
                "Uploaded file: {0}<br />" & _
                "File size (in bytes): {1:N0}<br />" & _
                "Content-type: {2}", _
                UploadTest.FileName, _
                UploadTest.FileBytes.Length, _
                UploadTest.PostedFile.ContentType)

        ' Save the file
        Dim filePath As String = _
            Server.MapPath("~/Brochures/" & UploadTest.FileName)
        UploadTest.SaveAs(filePath)
    End If
End Sub
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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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