BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excel Activex

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX)
View previous topic :: View next topic  
Author Message
William Westbrooks
Guest





PostPosted: Mon Jun 23, 2003 11:27 pm    Post subject: Excel Activex Reply with quote



Hi

Can any one tell me why I am getting an error that says a memory adderes
must be taken, which is being caused by the function
(TVariant)ExcelSheet->Cells->get_Item((TVariant)DataRow,(TVariant)(DataCol-1
)). When ever I comment this function out the error goes away or if I
compile the project in debug mode the function doesn't cause an error at
all. Only in release mode does the error occur. The cursor haults at the end
of the TDMWExcelForm4 function which get_Item is being called from when this
compiler error occurs, but it is caused by
(TVariant)ExcelSheet->Cells->get_Item((TVariant)DataRow,(TVariant)(DataCol-1
)). My code is written below.

void __fastcall TDMWExcelForm4::tsGrid1CellLoaded(TObject *Sender,int
DataCol, int DataRow, Variant &Value) {

//If this is the first column then fill in the row numbers else retrieve
the excel file values.
if(DataCol == 1) {
CellWidth = tsGrid1->Canvas->TextWidth(IntToStr(DataRow));
if(tsGrid1->Col[1]->Width < CellWidth) {
tsGrid1->Col[1]->Width = CellWidth;
}
Value = IntToStr(DataRow);
} else {

try {
CellValue =
(TVariant)ExcelSheet->Cells->get_Item((TVariant)DataRow,(TVariant)(DataCol-1
));

// If this is not an empty string
if(strcmp(CellValue.c_str(),"")!=0) {

// Make sure the column width is large enough for the data
CellWidth = tsGrid1->Canvas->TextWidth(CellValue);
if(tsGrid1->Col[DataCol]->Width < CellWidth+5) {
tsGrid1->Col[DataCol]->Width = CellWidth+10;
}

// Place the data in the table
Value = CellValue;
}
} catch(...) {
// Catch any errors getting excel values
Value = "";
}
}
}




Back to top
William
Guest





PostPosted: Tue Jun 24, 2003 9:06 am    Post subject: Re: Excel Activex Reply with quote



Can anyone tell me if there is a macro in debug mode that enables the
function ExcelSheet->Cells->get_Item to compile fine in debug mode. I can't
figure out why this causes an error in release mode.

"William Westbrooks" <wwestbrooks (AT) greggengineering (DOT) com> wrote

Quote:
Hi

Can any one tell me why I am getting an error that says a memory
adderes
must be taken, which is being caused by the function

(TVariant)ExcelSheet->Cells->get_Item((TVariant)DataRow,(TVariant)(DataCol-1
)). When ever I comment this function out the error goes away or if I
compile the project in debug mode the function doesn't cause an error at
all. Only in release mode does the error occur. The cursor haults at the
end
of the TDMWExcelForm4 function which get_Item is being called from when
this
compiler error occurs, but it is caused by

(TVariant)ExcelSheet->Cells->get_Item((TVariant)DataRow,(TVariant)(DataCol-1
)). My code is written below.

void __fastcall TDMWExcelForm4::tsGrid1CellLoaded(TObject *Sender,int
DataCol, int DataRow, Variant &Value) {

//If this is the first column then fill in the row numbers else retrieve
the excel file values.
if(DataCol == 1) {
CellWidth = tsGrid1->Canvas->TextWidth(IntToStr(DataRow));
if(tsGrid1->Col[1]->Width < CellWidth) {
tsGrid1->Col[1]->Width = CellWidth;
}
Value = IntToStr(DataRow);
} else {

try {
CellValue =

(TVariant)ExcelSheet->Cells->get_Item((TVariant)DataRow,(TVariant)(DataCol-1
));

// If this is not an empty string
if(strcmp(CellValue.c_str(),"")!=0) {

// Make sure the column width is large enough for the data
CellWidth = tsGrid1->Canvas->TextWidth(CellValue);
if(tsGrid1->Col[DataCol]->Width < CellWidth+5) {
tsGrid1->Col[DataCol]->Width = CellWidth+10;
}

// Place the data in the table
Value = CellValue;
}
} catch(...) {
// Catch any errors getting excel values
Value = "";
}
}
}






Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.