 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
nfieraru@gmail.com Guest
|
Posted: Tue Sep 06, 2005 2:20 am Post subject: Requery information from Excel |
|
|
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
|
Posted: Fri Sep 09, 2005 7:42 pm Post subject: Re: Requery information from Excel |
|
|
Hoi Nicolae
Take a look here:
<http://tinyurl.com/8m5nw>
which links to
<http://delphi.wikicities.com/wiki/Delphi_Newsgroups>
|
|
| Back to top |
|
 |
|
|
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
|
|