BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Requery information from Excel

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
nfieraru@gmail.com
Guest





PostPosted: Tue Sep 06, 2005 2:20 am    Post subject: Requery information from Excel Reply with quote



Hi All,

I am working on a program that has to read a value from an Excel file.
I use Borland C++ Builder, but I hope I will find help in here.

The excel document I am using gets written by another program that
dumps information into one spreadsheet every few seconds.

What I want to do is to be able to click repeatedly on the button and
to show the new values from the spreadsheet.

Because in the end I will use a function on timer to read the values,
and the refresh period is about 5 seconds, I suppose I must leave the
ExcelApplication open in my program, just to requery somehow the
spreadsheet.

Regards,
Nicolae

Here is the code I use:

void __fastcall TForm1::FormActivate(TObject *Sender)
{

ExcelApplication1->AutoConnect = false;
ExcelApplication1->ConnectKind = ckNewInstance;
ExcelWorkbook1->AutoConnect = false;
ExcelWorkbook1->ConnectKind = ckAttachToInterface;
ExcelWorksheet1->AutoConnect = false;
ExcelWorksheet1->ConnectKind = ckAttachToInterface;

ExcelApplication1->Workbooks->Open(StringToOleStr("C:\MyExcelFile.xls"));
ExcelApplication1->set_Visible(LOCALE_SYSTEM_DEFAULT,false);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Excel_2k::RangePtr Cell;


ExcelWorksheet1->ConnectTo(ExcelApplication1->Worksheets->get_Item((TVariant)1));

Cell=ExcelWorksheet1->get_Range((TVariant)"G13", (TVariant)"G13");
Edit1->Text=OleVariant(Cell->get_Value());
}

Back to top
Riki Wiki
Guest





PostPosted: Fri Sep 09, 2005 7:42 pm    Post subject: Re: Requery information from Excel Reply with quote



Hoi Nicolae

Take a look here:
<http://tinyurl.com/8m5nw>
which links to
<http://delphi.wikicities.com/wiki/Delphi_Newsgroups>
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.