Upload type=File into memory

Hello,
I would like to upload an excel file into memory.  I do not want to save it any where, just bring it on up to memory, parse throught the excel file into properties on an object and release it from memory.  I already have the class objects with the properties I want to populate, and I know how to parse a physical excel file if I  just pass the path to the excel object...

My question is how do I pass the file loaded into memory into an object with out first saving the file on the server?  Thanks
LVL 2
ispcorpAsked:
Who is Participating?
 
fritz_the_blankConnect With a Mentor Commented:
I don't believe that you can. In order to get it into memory, you would first have to open it, and of course, it would have to be on your server to do so.

FtB
0
 
danataylorCommented:
Don't  know exactly what you mean by uploading to memory but this will stuff your data into an Excel spreadsheet on the client machine for review.  If you don't want to save it to the hard drive then just close Excel without saving.

<%@ Language=VBScript %>
<html xmlns:o="urn:schemas-microsoft-com:office:office"             <%' Office XML Namespace    %>
          xmlns:x="urn:schemas-microsoft-com:office:excel">           <%' Excel XML Namespace     %>
<HEAD>
</HEAD>
<BODY>
<%
Response.ContentType = "application/vnd.ms-excel"
Response.Write "<TABLE>"
Response.Write "<TR><TD colspan=3>Get all the fields you need from your database.</TD></TR>"
Response.Write "<TR><TD colspan=3>Then cycle through them as you normally would.</TD></TR>"
Response.Write "<TR><TD colspan=3>Then put them in a table for formatting just like you would in a Web Table.</TD></TR>"
Response.Write "<TR><TD colspan=3></TD></TR>"

Response.Write "<TR>"
Response.Write "<TH>Name</TH>"
Response.Write "<TH>Address</TH>"
Response.Write "<TH>City-State-ZIP</TH>"
Response.Write "</TR>"

dim I
for I = 1 to 10
Response.Write "<TR>"
Response.Write "<TD>Fname_Lname_" & I & "</TD>"
Response.Write "<TD>Address_" & I & "</TD>"
Response.Write "<TD>City_State_ZIP_" & I & "</TD>"
Response.Write "</TR>"
next

Response.Write "</TABLE>"
%>
</BODY>
</HTML>
0
 
ispcorpAuthor Commented:
Ok, I'll wait a day and see if anybody else gives me a different response.  If its not possible, then I'll give you the points.  Thanks, though....
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
ispcorpAuthor Commented:
Hey DanaTaylor...What I mean by uploading it into memory is to take the "FILE", which is designation by the following html tag...

<Input ID="MyFile" Type="File" accept="text/comma-separated-values"  RunAt="Server" Size="40">

and take the "myFile" object, pass it into another object, open it (but not save it), parse it and then release it from memory.  
0
 
danataylorCommented:
Oh!  I understand now.  Tricky...I'm with Fritz - Don't think you can do it.

Of course, usually, as soon as I say that someone shows me how...

Then someone else shows me how to do it better...
0
 
fritz_the_blankCommented:
If the excel file existed on another server, you could try using something like this to get a text string from it:

Function GetHTML(strURL)
      Dim objXMLHTTP, strReturn
      Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
      objXMLHTTP.Open "GET", strURL, False
      objXMLHTTP.Send
      strReturn = objXMLHTTP.responseText
      Set objXMLHTTP = Nothing
      GetHTML = strReturn
End Function

That would give you the contents as a string variabile, but it doesn't sound like this matches your situation and this is the only way that I know how to do it.


FtB
0
 
ispcorpAuthor Commented:
Yes, its doens't match my situation because I would like to reference it just like I would if I opened up a physical excel file on my server.  By the way, I should also mention that I'm coding using VB.NET...
0
 
fritz_the_blankCommented:
Still no difference there--there is no simple way to pass the contents of a file on the client to a memory variable on the server.

FtB
0
 
ispcorpAuthor Commented:
I'm trying out a way of passing in the hmtl control and opening it up with the excel api using the PostedFile.FileName property.  I doubt it will work, but its worth a try...

-Tom
0
 
fritz_the_blankCommented:
No luck?

If you ever come across a solution, please post it here!


FtB
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.