Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Opening Excel with a stream

Hi All,

I am trying to get Excel to open using the contents of a stream that I
have populated from a database. Are there any samples/examples I can
review /

The code looks something like this (although I have removed error
handling for clarity):

ADO::_RecordsetPtr pRS("ADODB.Recordset",false);

_variant_t vRows;
_bstr_t bstrSelect("SELECT * from MyTable where name = 'Mysheet'");
pRS = m_pConn-Execute(bstrSelect, &vRows,0);

ADO::_StreamPtr pStr("ADODB.Stream");
pStr-Type = ADO::adTypeBinary;
pStr-Open
(vtMissing,ADO::adModeUnknown,ADO::adOpenStreamUns pecified,"","");

pStr-Write(pRS-GetFields()-GetItem((_variant_t)"DATA")-GetValue());


This works as I can use the following to open the spreadsheet
_bstr_t bstrFile("C:\Tmp\MySheet.xls");
pStr-SaveToFile(bstrFile,ADO::adSaveCreateNotExist);
LPDISPATCH lpDisp;
m_app.CreateDispatch("Excel.Application")lpDisp = m_app.GetWorkbooks();
ASSERT(lpDisp);
m_books.AttachDispatch(lpDisp);
m_books.Open
(bstrFile,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt, vOpt,vOpt,vOpt,vOpt);


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Opening Excel with a stream

The only way I know is to open Excel workbook from
commandline.

Shell(ExcelPath & " " & bstrFile & " /cmd " & vopt1 & " "
& vopt2 & " " & voptn)



-----Original Message-----
Hi All,

I am trying to get Excel to open using the contents of a

stream that I
have populated from a database. Are there any

samples/examples I can
review /

The code looks something like this (although I have

removed error
handling for clarity):

ADO::_RecordsetPtr pRS("ADODB.Recordset",false);

_variant_t vRows;
_bstr_t bstrSelect("SELECT * from MyTable where name

= 'Mysheet'");
pRS = m_pConn-Execute(bstrSelect, &vRows,0);

ADO::_StreamPtr pStr("ADODB.Stream");
pStr-Type = ADO::adTypeBinary;
pStr-Open

(vtMissing,ADO::adModeUnknown,ADO::adOpenStreamUns pecified,
"","");

pStr-Write(pRS-GetFields()-GetItem((_variant_t)"DATA")-
GetValue());


This works as I can use the following to open the

spreadsheet
_bstr_t bstrFile("C:\Tmp\MySheet.xls");
pStr-SaveToFile(bstrFile,ADO::adSaveCreateNotExist);
LPDISPATCH lpDisp;
m_app.CreateDispatch("Excel.Application")lpDisp =

m_app.GetWorkbooks();
ASSERT(lpDisp);
m_books.AttachDispatch(lpDisp);
m_books.Open

(bstrFile,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt, vOpt,vOpt
,vOpt,vOpt);


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Opening Excel with a stream

Thanks for the suggestion but that is not really what I want. I already
have the file loaded into a stream from a database and I do not want to
have to create a temporary file and then load it. This will mean I have
to delete the temporary file etc and we all know that leads to messy tmp
directories full of orphaned files.

TIA
John The One

"losmac" wrote in news:012601c3bd03
:

The only way I know is to open Excel workbook from
commandline.

Shell(ExcelPath & " " & bstrFile & " /cmd " & vopt1 & " "
& vopt2 & " " & voptn)



-----Original Message-----
Hi All,

I am trying to get Excel to open using the contents of a

stream that I
have populated from a database. Are there any

samples/examples I can
review /

The code looks something like this (although I have

removed error
handling for clarity):

ADO::_RecordsetPtr pRS("ADODB.Recordset",false);

_variant_t vRows;
_bstr_t bstrSelect("SELECT * from MyTable where name

= 'Mysheet'");
pRS = m_pConn-Execute(bstrSelect, &vRows,0);

ADO::_StreamPtr pStr("ADODB.Stream");
pStr-Type = ADO::adTypeBinary;
pStr-Open

(vtMissing,ADO::adModeUnknown,ADO::adOpenStreamUns pecified,
"","");

pStr-Write(pRS-GetFields()-GetItem((_variant_t)"DATA")-
GetValue());


This works as I can use the following to open the

spreadsheet
_bstr_t bstrFile("C:\Tmp\MySheet.xls");
pStr-SaveToFile(bstrFile,ADO::adSaveCreateNotExist);
LPDISPATCH lpDisp;
m_app.CreateDispatch("Excel.Application")lpDis p =

m_app.GetWorkbooks();
ASSERT(lpDisp);
m_books.AttachDispatch(lpDisp);
m_books.Open

(bstrFile,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt,vOpt, vOpt,vOpt
,vOpt,vOpt);


.



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
How to calculate IRR from a monthly income stream rflegeis Excel Discussion (Misc queries) 2 February 10th 06 09:07 PM
stream read error bembaman Excel Discussion (Misc queries) 3 December 23rd 05 04:53 AM
PV of uneven stream of cash flows PJF Excel Worksheet Functions 8 October 30th 05 01:16 AM
How can I figure present value of a stream of payments? shep New Users to Excel 1 December 9th 04 10:05 PM
Command Button Code Stream lining JDonaghue Excel Programming 1 November 11th 03 07:47 PM


All times are GMT +1. The time now is 03:23 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"