 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
William Westbrooks Guest
|
Posted: Mon Jun 23, 2003 11:27 pm Post subject: Excel Activex |
|
|
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
|
Posted: Tue Jun 24, 2003 9:06 am Post subject: Re: Excel Activex |
|
|
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 |
|
 |
|
|
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
|
|