Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loading a spreadsheet from memory

I have a program which has an xsl file sitting in a blob of memory.

I want to use the Excel object model to load up the blob, and to read
the rows/columns etc.

Is there any way to do this *without* having to save my blob to a file
on the hdd first? I would like to keep everything in memory if
possible, since once the blob has been processed, it is discarded.

TIA,
Pete

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Loading a spreadsheet from memory

Peter,

I am unfamiliar with the programming term "blob".
However, if your data is stored in an array then
data in an array can be transferred directly to
an Excel worksheet...
'-------------------------------
Sub Test()
Dim strArray() As String
Dim i As Long
Dim j As Long
ReDim strArray(1 To 10, 1 To 10)

For i = 1 To 10
For j = 1 To 10
strArray(i, j) = i * j
Next
Next
Worksheets(1).Range("A1:J10").Value = strArray

End Sub
'------------------------------
Regards,
Jim Cone
San Francisco, USA


"Peter Hurford" wrote in message
oups.com...
I have a program which has an xsl file sitting in a blob of memory.
I want to use the Excel object model to load up the blob, and to read
the rows/columns etc.
Is there any way to do this *without* having to save my blob to a file
on the hdd first? I would like to keep everything in memory if
possible, since once the blob has been processed, it is discarded.
TIA,
Pete


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loading a spreadsheet from memory

Sorry, looks like I didn't ask the question very well. blob = binary
large object.

Imagine you open a spreadsheet, just running Excel interactively. The
file you load up sits on the disk, right? And you just issue a "File |
Open" command, select the filename, and you're away...

And of course there's nothing to stop you doing exactly the same thing
programmatically with vba.

Well, in my case I have a program that wants to load up a spreadsheet.
Only thing is, the spreadsheet isn't a file on the disk, it is sitting
in a chunk of the program's memory. Now, as far as my program is
concerned it is just a bunch of binary data, won't make any sense to it
(just the same as if you open an xls file in notepad).

So, the thing to do is to load this chunk of memory into Excel - then I
can use the excel object model to peek at the row/column values.

Hence my earlier question. I want to be able to load a spreadsheet from
memory rather than from a physical file. Any takers?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loading a spreadsheet from memory

Its actually coming in from an http POST.

I think the issue is not necessarily the format that the "file" is in,
more the fact that it is in memory rather than on disk. I've thought
about what you said and I think even if the file was in csv format,
say, I'd still need either to parse it myself (yuk), or to get it onto
disk for Excel to parse (which is the same problem that I already
have!). Plus, either of these options involves saying to the users "you
must export the file in such-and-such a format for this to work", which
is a lot more hassle than saying to them "just save it as a regular xls
file".

I've bitten the bullet for now and saved the file temporarily on the
hdd, but I'm going to keep thinking about this one since hitting the
hdd will slow things down somewhat.

Any further ideas appreciated.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loading a spreadsheet from memory

Getting the file in memory is the easy bit! It's just an <input
type="file" tag on an html form.

If you don't know html, that probably doesn't mean much to you. But
imagine a web-based email client, say. There's probably a button called
"Add attachment" which will show you a "File Open" common dialog. You
choose a filename and hit the "Send" button. Behind the scenes, that
file you selected is uploaded to the web server (along with subject,
body fields etc. etc.). So at the server, it has to take the input,
turn it into an email, and take this uploaded file and turn it into an
attachment.

I'm doing the same kind of thing except I'm not building an email
client, I'm building something that will interpret a spreadsheet.

As regards "impressive", it obviously sounds more glamorous than it
actually is!

Pete



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Loading a spreadsheet from memory


"Peter Hurford" wrote in message
oups.com...
I have a program which has an xsl file sitting in a blob of memory.

I want to use the Excel object model to load up the blob, and to read
the rows/columns etc.

Is there any way to do this *without* having to save my blob to a file
on the hdd first? I would like to keep everything in memory if
possible, since once the blob has been processed, it is discarded.

TIA,
Pete


If you want to everything to be in memory, you should use a RAM Disk. It
will appear as a hdd but it will use RAM
http://www.winsoft.sk/ramdisk.htm

/Fredrik


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Loading a spreadsheet from memory

I have a program which has an xsl file sitting in a blob of memory.
I want to use the Excel object model to load up the blob, and to read
the rows/columns etc.


I don't know for sure, but I don't think that the Excel Object Model offers
any functions for handling memory management.

Two options I can see:
-1- Use vba to call win32 memory management api
(shared memory and stuffs) to extract information from the blob.

-2- If you are using Excel2003 + Vitual Studio .NET, you can use
"Visual Studio Tools for MS Office" (VSTO);

You can use c#/vb.net to deal with the
xls file in memory and, with help of VSTO, transform and save
it in excel format.


HTH --- arunkhemlai







Is there any way to do this *without* having to save my blob to a file
on the hdd first? I would like to keep everything in memory if
possible, since once the blob has been processed, it is discarded.

TIA,
Pete


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Loading a spreadsheet from memory

Hi Peter,

Did you ever find a solution to this problem? I'm wanting to do the same
thing (basically load a file from a stream) but can't find any references to
doing this.

Not sure if you ran into this as well, but I am trying to open files from a
web server, which works fine, but if I try to open 1 file, it doesn't work
as the file names take on the name of the server, and you can't open 1 file
with the same name.

For e.g. you go File|open "http://myweb.com/somefile.aspx", assuming the
aspx returns an output type (MIME type) of excel, this will open fine, will
be read-only and will be called 'myweb'. If you then try to open
"http://myweb.com/someotherfile.aspx", this fails because excel wants to name
the file 'myweb' but can't as there's already a file there called that. How
can we change the filename without having to save it to disk, and preferably
in code.

Any takers?!?!

"Peter Hurford" wrote:

I have a program which has an xsl file sitting in a blob of memory.

I want to use the Excel object model to load up the blob, and to read
the rows/columns etc.

Is there any way to do this *without* having to save my blob to a file
on the hdd first? I would like to keep everything in memory if
possible, since once the blob has been processed, it is discarded.

TIA,
Pete


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Loading a spreadsheet from memory

I wonder why Outlook and exchange know to rename a open file with a (1)
after the name -- Book1 becomes Book1(1) when opened again-- but the
method you are using won't.


"stevefromoz" wrote in message
...
Hi Peter,

Did you ever find a solution to this problem? I'm wanting to do the same
thing (basically load a file from a stream) but can't find any references
to
doing this.

Not sure if you ran into this as well, but I am trying to open files from
a
web server, which works fine, but if I try to open 1 file, it doesn't
work
as the file names take on the name of the server, and you can't open 1
file
with the same name.

For e.g. you go File|open "http://myweb.com/somefile.aspx", assuming the
aspx returns an output type (MIME type) of excel, this will open fine,
will
be read-only and will be called 'myweb'. If you then try to open
"http://myweb.com/someotherfile.aspx", this fails because excel wants to
name
the file 'myweb' but can't as there's already a file there called that.
How
can we change the filename without having to save it to disk, and
preferably
in code.

Any takers?!?!

"Peter Hurford" wrote:

I have a program which has an xsl file sitting in a blob of memory.

I want to use the Excel object model to load up the blob, and to read
the rows/columns etc.

Is there any way to do this *without* having to save my blob to a file
on the hdd first? I would like to keep everything in memory if
possible, since once the blob has been processed, it is discarded.

TIA,
Pete




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Loading a spreadsheet from memory

I don't understand it either :-S

I'm just using Application.Workbooks.Open("url")

s.

"William Benson" wrote:

I wonder why Outlook and exchange know to rename a open file with a (1)
after the name -- Book1 becomes Book1(1) when opened again-- but the
method you are using won't.


"stevefromoz" wrote in message
...
Hi Peter,

Did you ever find a solution to this problem? I'm wanting to do the same
thing (basically load a file from a stream) but can't find any references
to
doing this.

Not sure if you ran into this as well, but I am trying to open files from
a
web server, which works fine, but if I try to open 1 file, it doesn't
work
as the file names take on the name of the server, and you can't open 1
file
with the same name.

For e.g. you go File|open "http://myweb.com/somefile.aspx", assuming the
aspx returns an output type (MIME type) of excel, this will open fine,
will
be read-only and will be called 'myweb'. If you then try to open
"http://myweb.com/someotherfile.aspx", this fails because excel wants to
name
the file 'myweb' but can't as there's already a file there called that.
How
can we change the filename without having to save it to disk, and
preferably
in code.

Any takers?!?!

"Peter Hurford" wrote:

I have a program which has an xsl file sitting in a blob of memory.

I want to use the Excel object model to load up the blob, and to read
the rows/columns etc.

Is there any way to do this *without* having to save my blob to a file
on the hdd first? I would like to keep everything in memory if
possible, since once the blob has been processed, it is discarded.

TIA,
Pete





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not Enough Memory opening 2nd spreadsheet Pete Harris Excel Discussion (Misc queries) 2 March 14th 08 04:03 PM
Remove content when saving / loading spreadsheet EZdoesIT Excel Worksheet Functions 4 November 13th 06 03:42 PM
Loading a linked spreadsheet, Microsoft Visual Basic, error while. Wacher Excel Discussion (Misc queries) 0 April 18th 05 03:15 PM
Memory expanding spreadsheet JohnUK Excel Programming 0 June 2nd 04 08:37 PM
Insufficient memory error using shared excel spreadsheet Eric Lustig Excel Programming 1 September 26th 03 06:34 PM


All times are GMT +1. The time now is 01:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"