Hi team,
While fetching TdxSpreadSheet I am getting below error also attached screen shot .
could not convert variant of type null in to type (OleStr)
Below, what we are using code for the same.
Var
siCell : Variant
Begin
ATableView := TdxSpreadSheet.ActiveSheetAsTable;
siCell := ATableView.Cells[(123 - 1),0].AsVariant;
ATableView.CreateCell((123 - 1), 0).AsString := FieldByName('AcctNum');
siCell:= '' ;
end
Hi team,
I have tried below code and above error is gone but access violation is coming now . attached same .
if not VarIsSoftNull(ATableView.Cells[(123- 1),0].AsString) then
siCell := ATableView.Cells[(123 - 1),0].AsVariant;
Updated correct code :
if not VarIsSoftNull(ATableView.Cells[(123- 1),0].AsVariant) then
siCell := ATableView.Cells[(123 - 1),0].AsVariant;
Hello Manoj,
It is difficult to answer why this happens without examining a sample project. I do not have the 'AcctNum' object on my side and it is unclear what the FieldByName method does. Would you please provide us with a small sample project so we can correctly replicate your scenario?
As a side note, I do not think that it is reliable to use the ATableView.Cells array. Some cells may be nil in Spreadsheet documents. It is better to always use the ATableView.CreateCell method instead. If a certain cell is nil, it will be automatically created in this case.
Thanks Paulo,
But I am getting error at this point .
if not VarIsSoftNull(ATableView.Cells[(123- 1),0].AsVariant) then
begin
end ;
How I can use ATableView.CreateCell method here ?