Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use TExcelApplication?

1,528 views
Skip to first unread message

JillH

unread,
Feb 28, 2003, 2:16:25 PM2/28/03
to
I am looking for some documentation on using the Excel components in CPP
Builder. I've found a few code samples on the web and on Borland's site but
they are incomplete and undocumented. I've tried experimenting but with no
luck. I can interface from Delphi but it doesn't seem to work the same at
all from CB. I could really use some comprehensive documentation with
examples. Anyone have any suggestions?

Thanks in advance.

jheske

hts

unread,
Mar 3, 2003, 12:33:13 AM3/3/03
to
U could read msdn.or u could read delphi excel example.its the same

"JillH" <jhe...@mindspring.com> wrote in message
news:3e5fb60e$1...@newsgroups.borland.com...

Roberto

unread,
Mar 5, 2003, 1:42:32 PM3/5/03
to

Here a Sample

If you have the Office and Excel installed , you can get some help in
C:\Program Files\Microsoft Office\Office\1046\VBAXL9.CHM for office 2000
or VBAXL10.CHM for office XP

There you can find the object of Excel , it is very similar to
TExcelApplication , but you have to make some agreement


// --------START
Excel_2k::RangePtr Cell;

// Configuring your Control
ExcelApplication1->AutoConnect=false;
ExcelApplication1->ConnectKind =ckNewInstance;
ExcelWorkbook1->AutoConnect=false;
ExcelWorkbook1->ConnectKind =ckAttachToInterface;
ExcelWorksheet1->AutoConnect=false;
ExcelWorksheet1->ConnectKind =ckAttachToInterface;

// Open Excel
ExcelApplication1->Workbooks->Open(StringToOleStr("C:\\Workbook1.xls"));
// Must put Full Path
ExcelApplication1->set_Visible(LOCALE_SYSTEM_DEFAULT,true);

// ----------- Putting values
Cell=ExcelApplication1->Cells->get_Range_((TVariant)"A1", (TVariant)"A1");
Cell->set_Value(TVariant("Application.Cells"));

ExcelWorksheet1->ConnectTo(ExcelApplication1->Worksheets->get_Item((TVariant
)1));
Cell=ExcelWorksheet1->get_Range((TVariant)"A4", (TVariant)"A4"); //
Cell->set_Value(TVariant("Application.Workseet.Range"));


ExcelWorkbook1->ConnectTo(ExcelApplication1->Workbooks->get_Item(TVariant(1)
));
ExcelWorksheet1->ConnectTo(ExcelWorkbook1->Sheets->get_Item((TVariant)1));
Cell=ExcelWorksheet1->get_Range((TVariant)"A3", (TVariant)"A3"); //
Cell->set_Value(TVariant("Workbooks.Workseet.Range"));
Cell=ExcelWorksheet1->get_Range((TVariant)"C1", (TVariant)"F5"); //
Cell->set_Value(TVariant("123"));


// ------------ Geting one Value
Cell=ExcelWorksheet1->get_Range((TVariant)"A1", (TVariant)"A1"); //
Edit3->Text=OleVariant(Cell->get_Value());

// ------------ Getting Range of Values
Cell=ExcelWorksheet1->get_Range((TVariant)"A1", (TVariant)"B2"); //
OleVariant mv;
mv=OleVariant(Cell->get_Value());
if(mv.IsArray()){ // confirma se e array
Edit1->Text=mv.ArrayDimCount();
Memo1->Lines->Append(mv.GetElement(1,1));
Memo1->Lines->Append(mv.GetElement(1,2));
Memo1->Lines->Append(mv.GetElement(2,1));
Memo1->Lines->Append(mv.GetElement(2,2));
}

// Close and Save your Work
// ExcelWorkbook1->Close((TVariant)true);

// Closing the Excel
// ExcelApplication1->Quit();

// --------END

Roberto

"JillH" <jhe...@mindspring.com> escreveu na mensagem
news:3e5fb60e$1...@newsgroups.borland.com...

Ilan Azbel

unread,
Mar 18, 2003, 8:04:23 AM3/18/03
to
Hello,

I copied the code below into my compiler and it seems to compile fine but I
get a "Class not registered" error when the thing starts running. Any idea
which objects I need to register, and how?

Thanks

Ilan

"Roberto" <ca...@charao.com.br> wrote in message
news:3e664519$1...@newsgroups.borland.com...

Alex Bakaev [TeamB]

unread,
Mar 18, 2003, 1:47:32 PM3/18/03
to
Ilan Azbel wrote:
> Hello,
>
> I copied the code below into my compiler and it seems to compile fine but I
> get a "Class not registered" error when the thing starts running. Any idea
> which objects I need to register, and how?
>
>
Do you have MS Office installed?

Ilan Azbel

unread,
Mar 19, 2003, 3:03:34 AM3/19/03
to
Yes, I have it installed. I use Excel often. I think all I need to do is
register one of the DLLs, but I cannot seem to find which one.


"Alex Bakaev [TeamB]" <zx...@att.net> wrote in message
news:3e77...@newsgroups.borland.com...

Alex Bakaev [TeamB]

unread,
Mar 19, 2003, 4:46:52 PM3/19/03
to
Ilan Azbel wrote:
> Yes, I have it installed. I use Excel often. I think all I need to do is
> register one of the DLLs, but I cannot seem to find which one.
>
>
>
Well, apparently, something is not registered/installed properly or an
incorrect GUID is used somewhere.

.a

Ilan Azbel

unread,
Mar 20, 2003, 8:44:22 AM3/20/03
to
That is obvous. Any idiot can tell you that. I am looking for the name of
the DLL that I need to register.


"Alex Bakaev [TeamB]" <zx...@att.net> wrote in message

news:3e78...@newsgroups.borland.com...

Roberto

unread,
Mar 20, 2003, 10:37:47 AM3/20/03
to
Take a look at menu <Project><Import Type Library> in the listBox look for

some like "Microsoft Excel 9.0 Object Library" , this list show all the
Type Library

registed in your system, but if you are work normaly with Excel Is because
it is regited

, in the [ADD] button you may register the C:\Program files\Microsoft
office\office\EXECEL9.OLB

with is the COM where is the class TExcelApplication and other usend in
CBuilder

I beleave , you some lost some other Type Library , or have
corrupted *.cpp e *.h
used by CBuilder to acesses EXCEL.exe

roberto

"Ilan Azbel" <il...@mdio.net> escreveu na mensagem
news:3e77...@newsgroups.borland.com...

Alex Bakaev [TeamB]

unread,
Mar 20, 2003, 2:44:50 PM3/20/03
to
Ilan Azbel wrote:
> That is obvous. Any idiot can tell you that. I am looking for the name of
> the DLL that I need to register.
>
>

Would an idiot be able to reinstall a product?

.a

Ilan Azbel

unread,
Mar 25, 2003, 8:16:10 AM3/25/03
to
Yes, but only an idiot would try that as the first option.


"Alex Bakaev [TeamB]" <zx...@att.net> wrote in message

news:3e7a19ec$1...@newsgroups.borland.com...

Alex Bakaev [TeamB]

unread,
Mar 25, 2003, 8:00:38 PM3/25/03
to
Ilan Azbel wrote:
> Yes, but only an idiot would try that as the first option.
>
>

Well, than a non-idiot should be able to trace into the call, see where
exactly the exception happens, figure out what GUID was used, and then
figure out what is that's not registered. I'm not sure I can ask of you
to do that though.
.a


Ilan Azbel

unread,
Mar 27, 2003, 8:52:13 AM3/27/03
to
peace please.

"Alex Bakaev [TeamB]" <zx...@att.net> wrote in message

news:3e80fb73$1...@newsgroups.borland.com...

0 new messages