Link to home
Start Free TrialLog in
Avatar of ispcorp
ispcorp

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of danataylor
danataylor

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>
Avatar of ispcorp

ASKER

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....
Avatar of ispcorp

ASKER

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.  
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...
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
Avatar of ispcorp

ASKER

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...
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
Avatar of ispcorp

ASKER

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
No luck?

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


FtB