C++builder is the Borland company after a successful product after Delphi, she set VB, VC + + and the advantages of Delphi in one and won the favor of the C language enthusiasts. Because most operators love to organize data in Microsoft Excel, this article introduces two ways to access Excel files with C++builder.
I. Manipulating Excel with OLE technology
OLE (Object linking and embedding) is the standard proposed by Microsoft, is a way to exchange data between applications, interoperability, MS OFFICE provides a strong OLE service function, VB, Delphi and C++builder and other languages can be customer way to Excel to submit commands, To access its data, which VB and Delphi is the simplest, in the syntax of the use of class VBA statements, this 99 48th of the "Operation in Delphi Excel," A article has introduced Delphi practice. We thought that C++builder copy Delphi, the results of the grammar is not compiled, can not find the details of this specific introduction. After repeated testing: the original C++builder using the indirect method, the Variant class variant provided by the four "methods" to the OLE service program to submit a manipulation command:
Variant Variant::OlePropertyGet(属性名,参数….);
// 取对象属性
Void Variant::OlePropertySet(属性名,参数….);
// 设置对象属性
Variant Variant::OleFunction(函数名,参数….);
// 运行对象的函数
void Variant::OleProcedure(过程名,参数….);
// 运行对象的过程
Its header file "Vcl\utilcls.h" must be embedded in the user program.
For these four long method names, you can redefine the macro statement in your program:
#define PG OlePropertyGet
#define PS OlePropertySet
#define FN OleFunction
#define PR OleProcedure