Access Excel File After Upload to Web Server Memory

  • Thread starter Jack Harrington
  • Start date
J

Jack Harrington

Using a web form with an input field of type "file", is there a way to
upload an Excel .XLS file into the web server's memory, access a sheet, and
copy the data into an ADO.NET DataSet without saving the .XLS file to the
server's hard drive? In other words, access the .XLS file while it's in the
server's memory as if it resided on the hard drive.

Thank you !!
Jack H.
 
N

Natty Gur

Hi,

Hi, you can use "Request.Files[0].InputStream" to read the file content
into byte array and update the data set.

refer to :
support.microsoft.com/default.aspx?kbid=308042

Dim ds As DataSet = New DataSet()
pAdapt.MissingSchemaAction = MissingSchemaAction.AddWithKey
pAdapt.Fill(ds, "UploadTable")

Dim row As DataRow
row = ds.Tables("UploadTable").NewRow()

byte[] arrByte = new byte[Request.Files[0].InputStream.Length] ;
Request.Files[0].InputStream.Read(arrByte,0,
(int)Request.Files[0].InputStream.Length);

row(0) = Request.Files[0].FileName
row(1) = arrByte

ds.Tables("UploadTable").Rows.Add(row)
pAdapt.Update(ds, "UploadTable")
pConn.Close()


Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,223
Latest member
Jurgen2087

Latest Threads

Top