Integer Overflow

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
Dmeade
Posts: 26
Joined: Tue Jul 16, 2013 7:22 am

Integer Overflow

Post by Dmeade »

Im using Xls Read Write version 5.20.49

if i create a new Excel sheet using microsoft Excel 2013
and add a Line Chart and save that file

create a new Delphi project and in the
project Options - compiling - Runtime Errors
if the Overflow checking and range checking are checked

and you try and read the xlsx file you get a
Integer overflow. exception

im not worried about the chart but we are unable to load the data from the excel file when this happens
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Integer Overflow

Post by larsa »

Hello

Overflow checking and range checking shall be turned off. Integers and arrays are used in such a way the these checks can't be used.
Lars Arvidsson, Axolot Data
Dmeade
Posts: 26
Joined: Tue Jul 16, 2013 7:22 am

Re: Integer Overflow

Post by Dmeade »

Version 5.20.50
still gets the integer overflow error
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Integer Overflow

Post by larsa »

Hello

Overflow checking shall still be turned off.
Lars Arvidsson, Axolot Data
Dmeade
Posts: 26
Joined: Tue Jul 16, 2013 7:22 am

Re: Integer Overflow

Post by Dmeade »

Version 5.20.51
still gets the integer overflow error
Dmeade
Posts: 26
Joined: Tue Jul 16, 2013 7:22 am

Re: Integer Overflow

Post by Dmeade »

version 5.20.52
getting the integer overflow error
d3nton
Posts: 133
Joined: Thu Oct 25, 2012 9:48 am

Re: Integer Overflow

Post by d3nton »

You can solve it by temporarily turning of range checks and overflow checks in unit xpgPXML.pas function TXpgReadXML.QNameHashA: longword;

Code: Select all

{$IFOPT R+}
  {$DEFINE R_PLUS}
  {$RANGECHECKS OFF}
{$ENDIF}
{$IFOPT Q+}
 {$DEFINE Q_PLUS}
  {$OVERFLOWCHECKS OFF}
{$ENDIF}
function TXpgReadXML.QNameHashB: longword;
var
  ..
begin
  ..
end;
{$IFDEF R_PLUS}
  {$RANGECHECKS ON}
  {$UNDEF R_PLUS}
{$ENDIF}
{$IFDEF Q_PLUS}
  {$OVERFLOWCHECKS ON}
  {$UNDEF Q_PLUS}
{$ENDIF}
@Lars: Could you add this to XLSReadWrite, please?
Dmeade
Posts: 26
Joined: Tue Jul 16, 2013 7:22 am

Re: Integer Overflow

Post by Dmeade »

version 5.20.53
getting the integer overflow error - in the default build

after adding d3nton's suggested solution - i'm no longer getting the error
Dmeade
Posts: 26
Joined: Tue Jul 16, 2013 7:22 am

Re: Integer Overflow

Post by Dmeade »

Using Version 5.20.56 default build
gets Integer overflow with xlsx files that have image or chart

I have added an example project to Github

Git link
https://github.com/dangas56/XLSWR_IntegerOverflow.git

zip files are here
https://github.com/dangas56/XLSWR_Integ ... /tag/1.0.1

Adding d3nton's suggested solution resolved the issue

is there a reason why its not in the release version?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Integer Overflow

Post by larsa »

Hello

As I wrote before, the code is written in such a way that overflow checking shall be turned off. The fix suggested by d3nton only solves one problem. The whole code must be checked before overflow checking can be on, and this will not happened. If you want to have overflow checking on, use the compiled dcu:s instead of compiling the source code.
Lars Arvidsson, Axolot Data
Post Reply