Ver Mensaje Individual
  #3  
Antiguo 13-10-2005
Avatar de OSKR
OSKR OSKR is offline
Miembro
 
Registrado: nov 2004
Ubicación: San Cristóbal/Táchira/Venezuela
Posts: 389
Reputación: 20
OSKR Va por buen camino
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();
  }
};
__________________
Los Estados Unidos parecen destinados por la Providencia para plagar la América de miserias a nombre de la libertad."
Simón Bolívar
(Carta al Coronel Inglés Patricio Cambell 05/08/1829).
Responder Con Cita