Hello,
I have problem with AsVariant. If cell is clear, funtion returns value "1". I think the problem is in GetAsVariant:
function TXLSWorksheet.GetAsVariant(ACol, ARow: integer): Variant;
var
Cell: TXLSCellItem;
begin
if FCells.FindCell(ACol,ARow,Cell) then begin
case FCells.CellType(@Cell) of
xctNone,
xctBlank: Result := 0;
// xctCurrency,
xctFloat: Result := FCells.GetFloat(@Cell);
xctString: Result := FCells.GetString(@Cell);
xctBoolean: Result := FCells.GetBoolean(@Cell);
xctError: Result := Xc12CellErrorNames[FCells.GetError(@Cell)];
xctFloatFormula: Result := FCells.GetFormulaValFloat(@Cell);
xctStringFormula: Result := FCells.GetFormulaValString(@Cell);
xctBooleanFormula: Result := FCells.GetFormulaValBoolean(@Cell);
xctErrorFormula: Result := Xc12CellErrorNames[FCells.GetFormulaValError(@Cell)];
end;
end
else
Result := varNull; <------------------------------- Here must be Null, not varNull which is varType and integer consts
end;
Thanks
Zdenek
AsVariant returns 1 if cell is clear
Re: AsVariant returns 1 if cell is clear
Hello
In the latest update AsVariant returns zero If there is an unknown variant type.
In the latest update AsVariant returns zero If there is an unknown variant type.
Lars Arvidsson, Axolot Data
Re: AsVariant returns 1 if cell is clear
I think it should return Null as this is a purpose of Variant type.
Z
Z
Re: AsVariant returns 1 if cell is clear
Hello
No, excel returns zero on empty cells and this is also how other functions work (AsInteger, AsFloat).
No, excel returns zero on empty cells and this is also how other functions work (AsInteger, AsFloat).
Lars Arvidsson, Axolot Data
Re: AsVariant returns 1 if cell is clear
Ok.
How can I find that htere is nothing in cell?
Now I'm using
if not FindCell() then result:=Null
but I also need test for Blank Cell. How can I test if cell is blank?
Thanks
Zdenek
How can I find that htere is nothing in cell?
Now I'm using
if not FindCell() then result:=Null
but I also need test for Blank Cell. How can I test if cell is blank?
Thanks
Zdenek
Re: AsVariant returns 1 if cell is clear
Hello
You can use CellType. Example:
You can use CellType. Example:
Code: Select all
case XLS.Sheets[0].CellType[2,2] of
xctNone : ; //* No cell.
xctBlank : ; //* Blank cell.
xctBoolean : ; //* Boolean cell.
xctError : ; //* Cell with an error value.
xctString : ; //* String cell.
xctFloat : ; //* Floating point cell.
xctFloatFormula : ; //* Formula cell where the result of the formula is a numeric value.
xctStringFormula : ; //* Formula cell where the result of the formula is a string value.
xctBooleanFormula: ; //* Formula cell where the result of the formula is a boolean value.
xctErrorFormula : ; //* Formula cell where the result of the formula is an error value.
end;
Lars Arvidsson, Axolot Data
Re: AsVariant returns 1 if cell is clear
That is what I'm looking for.
Thanks
Zdenek
Thanks
Zdenek