Yo habia creado esta clase (en Builder) para interactuar con el Excel, mira bien la parte de la creacion del libro y a partir de ahi la instruccion para llamar las hojas:
Código:
class Excel
{ public:
Variant xlApp;
Variant xlBooks;
Variant xlBook;
Variant xlSheets;
Variant xlSheet;
Variant xlRange;
void AbrirExcel(bool Visible)
{ xlApp = CreateOleObject("Excel.Application"); //LLamamos al Excel
xlApp.Exec(PropertySet("Visible") << Visible);
xlBooks=xlApp.Exec(PropertyGet("Workbooks")); //LLamamos al conjunto de libros
xlBooks.Exec(Procedure("Add")); //Le agregamos 1
xlBook = xlBooks.Exec(PropertyGet("Item")<<1); //LLamamos a ese libro
xlSheets = xlBook.Exec(PropertyGet("Worksheets")); //LLamamos al conjunto de hojas del primer libro
xlSheet = xlSheets.Exec(PropertyGet("Item") << 1); //LLamamos a la primera hoja
}
void Escribir(int fila, int colm, AnsiString Value)
{ AnsiString Celda=AnsiString((char)(64+colm))+AnsiString(fila);
xlRange= xlSheet.Exec(PropertyGet("Range") << Celda);
xlRange.Exec(PropertySet("Value") << Value);
}
void Escribir(int fila, int colm, AnsiString Value,AnsiString Formato)
{ AnsiString Celda=AnsiString((char)(64+colm))+AnsiString(fila);
xlRange= xlSheet.Exec(PropertyGet("Range") << Celda);
xlRange.Exec(PropertySet("Value") << Value.ToDouble());
xlRange.Exec(PropertySet("NumberFormat") << Formato);
}
void Guardar(AnsiString FileName)
{ xlBook.Exec(Procedure("SaveAs") << FileName); //FileName debe tener extensiòn .xls
}
void Cerrar(bool Close=false)
{ if( Close)
xlApp.Exec(Procedure("Quit"));
xlApp.Clear();
}
};