C# - Reading Excel files.

Posted on 2004-11-28
Last Modified: 2008-01-09
I have question on how to dealing with reading an Excel file and I really need some help. I created an ASP.NET page where user can upload an Excel file. (I used <INPUT type=FILE> ) After the user submit, I got the PostedFile.InputStream and stored it as binary array. The question is how would I convert that binary array into Excel object or put it into a DataGrid or DataSet where I could loop through and do my calculation.

I don't have the option of writing that buffer to the Server where I can re-open with the Excel object.
Question by:prosperion
    LVL 18

    Accepted Solution

    Hi prosperion,
    Why dont you save it as a file somewhere and then read it from there. Something like this

    and then you may add it in DataSet

    Assisted Solution

    Have you decided on an approach yet, prosperion?  It sounds like you do not have the option of saving the xls file to the server, is that correct?

    How much processing are you doing on this excel file?  Do you care about any VBA, or are you merely taking cell contents (formulas and formatting)?  What kind of browsers are you expecting to support?  Could you use any ActiveX controls, client-side?  An ActiveX control could convert your xls file content to xml (assuming you are excluding VBA for the time being, but that may be able to be handled as well) where you could input that stream into your object model for your calculations or processing.  The use of the ActiveX control, in order to limit the size of the control, would (reasonably) assume the client had the Excel API of one version or another.  There would be some messy parts involved, but all within reason.


    Author Comment

    We have actually figured this out, and decided to just save the file - and it seems to be working fine.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now