Fco. Javier Mart?nez Guest
|
Posted: Mon Jun 07, 2004 9:32 am Post subject: Excel whit Borland Builder c++ 4.0 |
|
|
Hello group.
First to excuse for my bad english. I write the messaje in my language
to the finis this message.
I have created a service whith one thread for working whit excell. Whe
i prove in my computer works correctly, but when i prove in another
equipment the aplication is waiting in the line that creates the OLE
Object. I send the code for somebody knows that i in the code can
need.
It can be tat i mus take some DLL to the equipment where I Install the
application?
void __fastcall CtrlLector::Execute()
{
//Las creo ahora para no estar todo el rato creando.
Variant XL = Unassigned; //file
Variant v0; //worbook
Variant v1; //page
.....
while(!Terminated){
//Reseteamos el buffer de lectura y leemos a ver si hay algo.
memset(lpBuf, ' ', sizeof(lpBuf));
rcard->ReadData(lpBuf,10);
//Comprobamos si ha leido correctamente. comprobamos que
reciba
//los codigos deseados.
if (strlen(lpBuf) == 7){
....
//initializes the Component Object Model(COM) library
HRESULT res = OleInitialize(NULL);
//Creo un Objeto de tipo aplicacion 'Excel'
/* IN THIS LINE THE APLICATION IS WAITING */
XL=CreateOleObject("Excel.Application"); //
*ofs << "Objeto Excel Application creado." << endl;
//Accedo a sus propiedades y metodos con
'OlePropertySet'
XL.OlePropertySet("Visible",Variant(true)); //Si
dedeamos que se visible.
*ofs << "Objeto hoja creado." << endl;
//Obtengo un objeto que será una coleccion de objetos
libros
v0=XL.OlePropertyGet("Workbooks");
//La Coleccion esta vacia y voy a añadir un libro
v0.OleProcedure("Add");
//A partir de la Coleccion obtengo el primer objeto
'libro'
v1=v0.OlePropertyGet("Item",Variant(1));
//A partir del objeto libro obtengo una coleccion de
hojas
v0=v1.OlePropertyGet("Worksheets") ;
//A partir de la coleccion de hojas accedo de objetos
hojas y las nombra
v0.OlePropertyGet("Item",1).OlePropertySet("Name","rcard");
*ofs << "Pagina renombrada." << endl;
//Escribimos el codigo deseado.
v1=v0.OlePropertyGet("Item",Variant(1));
//Obtengo un objeto hoja, a partir de la coleccion de
hojas y le pongo un valor.
v1.OlePropertyGet("Cells").OlePropertyGet("Item",Variant(1),Variant(1)).OlePropertySet("Value",Variant(aux));
*ofs << "Valor introducido." << endl;
//Guardamos y cerramos el libro.
XL.OlePropertySet("DisplayAlerts",Variant(false));
//suppress the warning dialog on closing the server
XL.OlePropertyGet("Workbooks").OlePropertyGet("Item",Variant(1)).OleProcedure("SaveAs","C:\Temp\rcard.xls");
XL.OleProcedure("Quit");
XL=Unassigned;
*ofs << "Objeto destruido." << endl;
//close the Component Object Model(COM) library
OleUninitialize();
}
ofs->flush();//Guardamo sel resultado en el log.
}
}
rcard->Close();
}
spanish:
He creado un servicio con un thread para trabajar con excell. Cuado
ejecuto el servicio en mi ordenador funciona correctamente. Si instalo
el servicio en otro equipo la aplicación se queda en la línea que creo
el objeto Ole.
¿Donde esta el problema, o que dll necesito copiar en el otro equipo
para que funcione el trabajo con excel?.
thanks to help me
|
|