 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Salvador Huertas Guest
|
Posted: Tue Apr 20, 2004 7:21 am Post subject: ExcelWorkbook Class Not Registred |
|
|
I'm using a component TExcelWorkbook that I have drop into a Form and when I
try use it and I call a member function allways I get the message "Class Not
Registred", the program compiles and link Ok without any error, the problem
araise at run time. I'm using BCB 5.0 and running in Windows XP
Professional.
Thanks in advance!!
Salvador.
|
|
| Back to top |
|
 |
BigStew Guest
|
Posted: Tue Apr 20, 2004 5:02 pm Post subject: Re: ExcelWorkbook Class Not Registred |
|
|
OK, start with the basic question, is Excel installed?
If it is, can we see your code?
Stew
"Salvador Huertas" <none@none> wrote
| Quote: | I'm using a component TExcelWorkbook that I have drop into a Form and when
I
try use it and I call a member function allways I get the message "Class
Not
Registred", the program compiles and link Ok without any error, the
problem
araise at run time. I'm using BCB 5.0 and running in Windows XP
Professional.
Thanks in advance!!
Salvador.
|
|
|
| Back to top |
|
 |
Salvador Huertas Guest
|
Posted: Tue Apr 20, 2004 9:17 pm Post subject: Re: ExcelWorkbook Class Not Registred |
|
|
Yes, de Excel it's installed. The code I had wrote it's:
Header file (Excel01.h)
*********************************************************************
// ===================================================================
// Tratamiento de Ficheros Excel
// ===================================================================
#include <treu.h>
#include <pluobjet.h>
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include "Excel_2K_SRVR.h"
class treuexcel {
private:
AnsiString name;
TExcelApplication *excelapp;
TExcelWorkbook *libro;
_Worksheet *hoja;
public:
treuexcel(TExcelApplication *excelapplica,TExcelWorkbook *wb);
bool apertura(AnsiString nombre,bool readonly);
bool cierre(void);
void selehoja(AnsiString nombre);
valor leercelda(int fila,int columna,int tipo);
void grabarcelda(int fila,int columna,valor &vale);
int indexcolumna(AnsiString letras);
AnsiString letrascomuna(int index);
bool grabar(void);
};
Class treuexcel implementation
****************************************************************
// =================================================================
// Definicion de la clase TreuExcel
// =================================================================
#include "Excel01.h"
treuexcel::treuexcel(TExcelApplication *excelappli,TExcelWorkbook *wb) {
excelapp=excelappli;
libro=wb;
}
bool treuexcel::apertura(AnsiString nombre,bool readonly) {
name=nombre;
excelapp->Connect();
libro->OpenLinks((wchar_t*)name.c_str(),readonly,0,0);
return true;
}
bool treuexcel::cierre(void) {
bool ret;
excelapp->Quit();
excelapp->Disconnect();
return ret;
}
void treuexcel::selehoja(AnsiString nombre) {
hoja=(_WorksheetPtr)libro->Worksheets->get_Item(nombre.c_str());
}
valor treuexcel::leercelda(int fila,int columna,int tipo) {
valor retorno;
AnsiString ret;
if (tipo==NUMER) {
retorno=double(hoja->Cells->get_Item(fila,columna));
}
if (tipo==SERIE) {
ret=AnsiString(hoja->Cells->get_Item(fila,columna));
retorno=ret.c_str();
}
return retorno;
}
void treuexcel::grabarcelda(int fila,int columna,valor &vale) {
int tipo;
tipo=vale.tipox();
if (tipo==NUMER) {
hoja->Cells->set_Item(fila,columna,numer(vale));
}
if (tipo==SERIE) {
hoja->Cells->set_Item(fila,columna,serie(vale));
}
}
int treuexcel::indexcolumna(AnsiString letras) {
int retorno;
return retorno;
}
AnsiString treuexcel::letrascomuna(int index) {
AnsiString retorno;
return retorno;
}
bool treuexcel::grabar(void) {
libro->Save(0);
return true;
}
Main Program
****************************************************************************
void __fastcall TForm1::Button2Click(TObject *Sender)
{
treuexcel treuexcelobjeto(ExcelApplication1,ExcelWorkbook1);
treuexcelobjeto.apertura("C:\Pases\pelillosbis.xls",false);
treuexcelobjeto.selehoja("Hoja1");
treuexcelobjeto.grabarcelda(3,8,"Hola Mundo");
treuexcelobjeto.grabar();
treuexcelobjeto.cierre();
}
The Olesys error "Class not registred" it's in the first line I use the
TExcelWorkbook1.
libro->OpenLinks((wchar_t*)name.c_str(),readonly,0,0);
Thanks in advance!!
Salvador.
|
|
| Back to top |
|
 |
BigStew Guest
|
Posted: Wed Apr 21, 2004 3:04 pm Post subject: Re: ExcelWorkbook Class Not Registred |
|
|
I've never used the OpenLink method before, so I'm not sure whether you're
using correctly.
The following change will open the spreadsheet...
bool treuexcel::apertura(AnsiString nombre,bool readonly) {
name=nombre;
excelapp->Connect();
//
libro->OpenLinks((wchar_t*)name.c_str(),TVariant(readonly),TVariant(0),0);
excelapp->Workbooks->Open(WideString(name));
libro->ConnectTo(excelapp->ActiveWorkbook);
return true;
}
....I won't comment on the usefulness of the return value of this function
should OpenLink/Open fail :-)
Stew
"Salvador Huertas" <none@none> wrote
| Quote: | Yes, de Excel it's installed. The code I had wrote it's:
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|