Floating point invalid operation when using Sheets.asFloat

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
d3nton
Posts: 133
Joined: Thu Oct 25, 2012 9:48 am

Floating point invalid operation when using Sheets.asFloat

Post by d3nton »

Hi!

I am using then new XLSReadWriteII 5.1 but I am having problems saving values as float:
The Delphi code below results in a 'Floating point invalid operation' in function TXLSCellMMU.EncodeNumber:

var
ExcelFile : TXLSReadWriteII5;
begin
ExcelFile := TXLSReadWriteII5.Create(nil);
ExcelFile.Filename := 'C:\output.xlsx';
ExcelFile.Sheets[0].InsertRows(0,0);
ExcelFile.Sheets[0].AsFloat[0, 0] := 10000000; <-
ExcelFile.Write;
end.

Please help.
Thanks d3nton
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Floating point invalid operation when using Sheets.asFloat

Post by larsa »

Hello

The problem is the delphi RoundTo function that is buggy. The behaivor of RoundTo has also changed in recent Delphi versions. When this exception happends, stop at the source code and change RoundTo to XLSRoundTo, or if you have XLSRoundTo, change to RoundTo.
Lars Arvidsson, Axolot Data
d3nton
Posts: 133
Joined: Thu Oct 25, 2012 9:48 am

Re: Floating point invalid operation when using Sheets.asFloat

Post by d3nton »

Okay thank you!
I see that you have already fixed this in the newest version :)
Post Reply