Access Excel File After Upload to Web Server Memory

  • Thread starter Thread starter Jack Harrington
  • Start date 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.
 
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
 
Back
Top