"floating point division by zero" with AutoWidthCols
-
- Posts: 12
- Joined: Tue Dec 17, 2013 4:56 pm
"floating point division by zero" with AutoWidthCols
Hi
When i use the AutoWidthCols(), this function be return a error - "floating point division by zero" .
In old version worked perfectly, but after update the component this problem has happened.
When i use the AutoWidthCols(), this function be return a error - "floating point division by zero" .
In old version worked perfectly, but after update the component this problem has happened.
-
- Posts: 15
- Joined: Thu Aug 29, 2013 5:45 pm
Re: "floating point division by zero" with AutoWidthCols
Hello,
I updated to the latest version and got the same error.
I updated to the latest version and got the same error.
Best regards,
Adriano Silva
Adriano Silva
Re: "floating point division by zero" with AutoWidthCols
Hello
I can't reproduce this. Tested with update 5.20.11
It the error persists, please provide a complete sample that reproduces the error.
I can't reproduce this. Tested with update 5.20.11
It the error persists, please provide a complete sample that reproduces the error.
Lars Arvidsson, Axolot Data
-
- Posts: 12
- Joined: Tue Dec 17, 2013 4:56 pm
Re: "floating point division by zero" with AutoWidthCols
Hi
I did the sample and the error still persist. This code:
XLS.Clear();
XLS[0].AsString[0, 0] := 'Testing Value 0';
XLS[0].AsString[0, 1] := 'Testing Value';
XLS[0].AsString[0, 2] := 'Testing';
XLS[0].AsString[0, 3] := 'Testing Value 0 Testing Value 0 Testing Value 0';
XLS[0].AsString[1, 0] := 'Testing';
XLS[0].AsString[1, 1] := 'Testing Value 0 Testing Value 0 Testing Value 0';
XLS[0].AsString[1, 2] := 'Testing';
XLS[0].AsString[1, 3] := 'Testing Value';
XLS[0].AutoWidthCols(0, 1);
XLS[0].Name := 'Teste';
XLS.Filename := 'C:\Test.xlsx';
XLS.Write;
I am using the latest version.
I did the sample and the error still persist. This code:
XLS.Clear();
XLS[0].AsString[0, 0] := 'Testing Value 0';
XLS[0].AsString[0, 1] := 'Testing Value';
XLS[0].AsString[0, 2] := 'Testing';
XLS[0].AsString[0, 3] := 'Testing Value 0 Testing Value 0 Testing Value 0';
XLS[0].AsString[1, 0] := 'Testing';
XLS[0].AsString[1, 1] := 'Testing Value 0 Testing Value 0 Testing Value 0';
XLS[0].AsString[1, 2] := 'Testing';
XLS[0].AsString[1, 3] := 'Testing Value';
XLS[0].AutoWidthCols(0, 1);
XLS[0].Name := 'Teste';
XLS.Filename := 'C:\Test.xlsx';
XLS.Write;
I am using the latest version.
Re: "floating point division by zero" with AutoWidthCols
Hello
Still no luck. Which Delphi version do you use?
Still no luck. Which Delphi version do you use?
Lars Arvidsson, Axolot Data
-
- Posts: 12
- Joined: Tue Dec 17, 2013 4:56 pm
Re: "floating point division by zero" with AutoWidthCols
Hi,
i´m using Delphi XE2
i´m using Delphi XE2
-
- Posts: 12
- Joined: Tue Dec 17, 2013 4:56 pm
Re: "floating point division by zero" with AutoWidthCols
Hi
when I was debugging the code of component, i found this code in 'XLSColumn5.pas'
//XLSColumn5.pas
procedure TXLSColumn.SetPixelWidth(const AValue: integer);
begin
SetWidth(Round(Trunc((AValue - 5) / FOwner.FStyles.StdFontWidth * 100 + 0.5) / 100) * 256);
end;
the value of StdFontWidth is ZERO, returning the error message.
continuing debug the code, i found in 'Xc12DataStyleSheet5.pas', this code:
{$ifdef XLS_XSS}
procedure TXc12Fonts.CalcStdFontWidthHeight;
var
i: integer;
S: AxUCString;
Sz: TSize;
DC: HDC;
begin
FStdFontWidth := 0;
DC := CreateIC('DISPLAY',Nil,Nil,Nil);
try
SelectObject(DC,Items[0].GetHandle(GetDeviceCaps(DC,LOGPIXELSY)));
for i := 1 to 10 do begin
S := StrDigits;
Windows.GetTextExtentPoint32W(DC,PWideChar(S),1,Sz);
if Sz.cx > FStdFontWidth then
FStdFontWidth := Sz.cx;
end;
FStdFontHeight := Items[0].FLF.lfHeight;
finally
DeleteDC(DC);
end;
end;
{$endif}
Here FStdFontWidth receives a value, but when the application is running this code not executed.
In none moment the directive XLS_XSS is defined, so this code came be ignored.
when I was debugging the code of component, i found this code in 'XLSColumn5.pas'
//XLSColumn5.pas
procedure TXLSColumn.SetPixelWidth(const AValue: integer);
begin
SetWidth(Round(Trunc((AValue - 5) / FOwner.FStyles.StdFontWidth * 100 + 0.5) / 100) * 256);
end;
the value of StdFontWidth is ZERO, returning the error message.
continuing debug the code, i found in 'Xc12DataStyleSheet5.pas', this code:
{$ifdef XLS_XSS}
procedure TXc12Fonts.CalcStdFontWidthHeight;
var
i: integer;
S: AxUCString;
Sz: TSize;
DC: HDC;
begin
FStdFontWidth := 0;
DC := CreateIC('DISPLAY',Nil,Nil,Nil);
try
SelectObject(DC,Items[0].GetHandle(GetDeviceCaps(DC,LOGPIXELSY)));
for i := 1 to 10 do begin
S := StrDigits;
Windows.GetTextExtentPoint32W(DC,PWideChar(S),1,Sz);
if Sz.cx > FStdFontWidth then
FStdFontWidth := Sz.cx;
end;
FStdFontHeight := Items[0].FLF.lfHeight;
finally
DeleteDC(DC);
end;
end;
{$endif}
Here FStdFontWidth receives a value, but when the application is running this code not executed.
In none moment the directive XLS_XSS is defined, so this code came be ignored.
-
- Posts: 15
- Joined: Thu Aug 29, 2013 5:45 pm
Re: "floating point division by zero" with AutoWidthCols
Hello,
I'm using Delphi 7 and XLSReadWriteII 5.20.11.
Code below:
sFileName := ExtractFilePath(Application.ExeName) + '\TestXLS.xlsx';
sMsg := '';
Try
xlsWorkbook.Clear;
xlsWorkbook.Version := xvExcel2007;
xlsWorkbook.Filename := sFileName;
xlsWorkSheet := xlsWorkbook.Sheets[0];
xlsWorkSheet.AsString[0, 0] := 'Value';
xlsWorkSheet.AsString[1, 0] := 'Formula';
xlsWorkSheet.AsString[2, 0] := 'Result';
xlsWorkSheet.AutoWidthCols(0, 2); // Here is when the error occurs
xlsWorkbook.Write;
Except
on E : Exception do
begin
MessageBox(Application.Handle, PChar(E.Message + ' - ' + sMsg), 'TestXLS', MB_OK + MB_ICONERROR);
end;
end;
I'm using Delphi 7 and XLSReadWriteII 5.20.11.
Code below:
sFileName := ExtractFilePath(Application.ExeName) + '\TestXLS.xlsx';
sMsg := '';
Try
xlsWorkbook.Clear;
xlsWorkbook.Version := xvExcel2007;
xlsWorkbook.Filename := sFileName;
xlsWorkSheet := xlsWorkbook.Sheets[0];
xlsWorkSheet.AsString[0, 0] := 'Value';
xlsWorkSheet.AsString[1, 0] := 'Formula';
xlsWorkSheet.AsString[2, 0] := 'Result';
xlsWorkSheet.AutoWidthCols(0, 2); // Here is when the error occurs
xlsWorkbook.Write;
Except
on E : Exception do
begin
MessageBox(Application.Handle, PChar(E.Message + ' - ' + sMsg), 'TestXLS', MB_OK + MB_ICONERROR);
end;
end;
Best regards,
Adriano Silva
Adriano Silva
Re: "floating point division by zero" with AutoWidthCols
Hello
Working fine with D7 as well. The latest update is 5.20.12. Please try that.
Working fine with D7 as well. The latest update is 5.20.12. Please try that.
Lars Arvidsson, Axolot Data
-
- Posts: 12
- Joined: Tue Dec 17, 2013 4:56 pm
Re: "floating point division by zero" with AutoWidthCols
Hello
I updated to the latest version (5.20.12), but the same error still persist.
I use delphi XE2
I updated to the latest version (5.20.12), but the same error still persist.
I use delphi XE2
-
- Posts: 17
- Joined: Fri Feb 01, 2013 8:24 pm
Re: "floating point division by zero" with AutoWidthCols
I got the same problem with Delphi Xe5.
Also the same error when inserting an image.
Regards,
RJvV
Also the same error when inserting an image.
Regards,
RJvV
Re: "floating point division by zero" with AutoWidthCols
Same with Delphi 7.
Re: "floating point division by zero" with AutoWidthCols
Hello
As I can't reproduce this error and hence debug the code, please check where/what in the source code that it is that causes this.
As I can't reproduce this error and hence debug the code, please check where/what in the source code that it is that causes this.
Lars Arvidsson, Axolot Data
-
- Posts: 17
- Joined: Fri Feb 01, 2013 8:24 pm
Re: "floating point division by zero" with AutoWidthCols
Hello,
I downloaded the latest version and removed all xlsread*.* files after deinstallation. Then I installed version 5.20.13 and now auto width and images word fine again. it must be some old source in my debug/ release dir. Strange but it works for me. So happy again!!
Regards,
RJ
I downloaded the latest version and removed all xlsread*.* files after deinstallation. Then I installed version 5.20.13 and now auto width and images word fine again. it must be some old source in my debug/ release dir. Strange but it works for me. So happy again!!
Regards,
RJ
-
- Posts: 15
- Joined: Thu Aug 29, 2013 5:45 pm
Re: "floating point division by zero" with AutoWidthCols
Hello,
The error occurs on file XLSColumn5.pas, line 328, in the procedure below:
procedure TXLSColumn.SetPixelWidth(const AValue: integer);
begin
SetWidth(Round(Trunc((AValue - 5) / FOwner.FStyles.StdFontWidth * 100 + 0.5) / 100) * 256);
end;
AValue has a integer value greater than 0 and FOwner.FStyles.StdFontWidth value is 0.
The error occurs on file XLSColumn5.pas, line 328, in the procedure below:
procedure TXLSColumn.SetPixelWidth(const AValue: integer);
begin
SetWidth(Round(Trunc((AValue - 5) / FOwner.FStyles.StdFontWidth * 100 + 0.5) / 100) * 256);
end;
AValue has a integer value greater than 0 and FOwner.FStyles.StdFontWidth value is 0.
Best regards,
Adriano Silva
Adriano Silva