Reading Excel files that have been uploaded to website

Soldato
Joined
27 Mar 2003
Posts
2,710
Hi All,

Wondering if anyone can shed any light on how I could possibly do the following:

I have a website that I would like people to be able to upload a list of email addresses from a excel/csv file so that they can then send an invitation email to these people through a website.

I currently have the ability to upload the excel file using the Telerik AsyncUpload control but can't figure out a way to read the contents of the file while it is still in memory as I don't want to have to save it to anywhere while performing this operation. Is this possible?

This is for a AJAX ASP.Net (C#) website and it would be nice to offer this as a potential solution rather than having to type in lots of email addresses.

Alternatively if anyone has a better solution I am open to ideas.

Thanks in advance.
 
Thanks for the info. But I am having a little issue Excel Data Reader as it seems to read .xls files fine but doesn't seem to read any excel 2010 files or at least not create a dataset from them.

sample code:
Code:
  if (e.IsValid)
            {
                FileStream myFile = e.File.InputStream as FileStream;
                if (myFile != null)
                {
                    IExcelDataReader excelReader = null;
                    if (e.File.FileName.Contains(".xlsx"))
                    {
                        excelReader = ExcelReaderFactory.CreateOpenXmlReader(myFile);
                    }
                    else if (e.File.FileName.Contains(".xls"))
                    {
                        excelReader = ExcelReaderFactory.CreateBinaryReader(myFile);

                    }
                    else
                    {
                        //TODO: do something here. when not an excel file. 
                    }
                    if (excelReader != null)
                    {
                        DataSet ds = excelReader.AsDataSet();
                        DataTable dt = null;


                        if (ds != null && ds.Tables.Count > 0)
                        {
                            dt = ds.Tables[0];
                            ParseEmailTable(dt);
                        }


                    }
                    else
                    {
                        //TODO something has gone wrong here. 
                    }
                }
                 
            }

It does seem that others have had the same sort off issue but no resolution has been found. If you have found a solution to this it would be great
 
UPDATE.

Turns out that the latest project files from the site have addressed these issues.

Seems that the download on the project page is an old build.

All sorted now and working like a dream. Has saved me many hours of work.
 
Back
Top Bottom