Yo también tuve ese problema hace tiempo.
Al moverte por las celdas tienes que tener
en cuenta que un celta esta formada for una letra y un número. Ejemplo: A1, A2, etc.Aqui te escribo el código que yo he utilizado
para pasar una tabla de Access a Excel.
Espero que te ayude.
include <vcl.h>
#pragma hdrstop
#include "Excel.h"
#include "Comobj.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
Table1->Active = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::ComboBox1Change(TObject *Sender)
{
Table1-> Active = false;
Table1->TableName = ComboBox1->Items->Strings[ComboBox1->ItemIndex];
Table1-> Active = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
int fila =1;
char columna ='A';
int numFilas = Table1-> RecordCount; //n° Filas
int numColumnas = Table1 -> FieldCount; // n° Columnas
Variant xlApp;
xlApp = CreateOleObject("Excel.Application");
xlApp.Exec(PropertySet("Visible") << true);
Variant xlBooks = xlApp.Exec(PropertyGet("Workbooks"));
xlBooks.Exec(Procedure("Add"));
Variant xlBook = xlBooks.Exec(PropertyGet("Item") <<1);
Variant xlSheets = xlBook.Exec(PropertyGet("Worksheets"));
Variant xlSheet = xlSheets.Exec(PropertyGet("Item") << 1);
while (fila <= numFilas)
{
columna ='A';
for (int j = 0; j < numColumnas; j++)
{
AnsiString pos = AnsiString(columna) + AnsiString(fila);
Variant Range = xlSheet.Exec(PropertyGet("Range") << pos);
Range.Exec(PropertySet("Value") << Table1->Fields->Fields[j]->AsString);
columna++;
}
Table1->Next();
fila++;
}
}
Un Saludo para Argentina.