Спасибо всем ! Сделал в результате сам и совсем по-другому !
Код |
//---------------------------------------------------------------------------
#include <vcl.h>
#include<windows.h> #include <comobj.hpp>
#include <string>
using namespace std;
//---------------------------------------------------------------------------
char *Rus(const char * Str);
char bufRus[512];
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender) {
Query1->Close(); Query1->SQL->Clear(); Query1->SQL->Add( "Выбираем например 5 полей" ); Query1->ExecSQL();
Query1->Active = true;
string FieldsName[5] = {"Pole1", "Pole2", "Pole3", "Pole4", "Pole5"};
Variant App,List;
App=CreateOleObject("Excel.Application"); App.OlePropertySet("SheetsInNewWorkbook",1); App.OlePropertyGet("Workbooks") .OleProcedure("Add"); List=App.OlePropertyGet("Worksheets") .OlePropertyGet("Item",1);
for(int j=0; j<5; j++) { List.OlePropertyGet("Cells").OlePropertyGet("Item",1,j+1).OlePropertySet( "Value", FieldsName[j].c_str() ); }
CGauge1->MinValue = 1; CGauge1->MaxValue = 5;
for(int j=1; j<=5; j++) {
Query1->First(); for(int i=2; i<=Query1->RecordCount+1; i++) {
Application->ProcessMessages();
string Buf = Query1->FieldByName( FieldsName[j-1].c_str() )->AsString.c_str(); List.OlePropertyGet("Cells").OlePropertyGet("Item",i,j).OlePropertySet( "Value", Rus( Buf.c_str() ) ); Query1->Next(); }
CGauge1->Progress = j;
} App.OlePropertySet("Visible",true); } //---------------------------------------------------------------------------
char *Rus(const char* Str) { OemToChar(Str,bufRus); return bufRus; }
//---------------------------------------------------------------------------
|
Осталось в класс завернуть, чтобы было универсально и красиво. |