Page 1 of 1
Problem reading Excel97 files with version 5.10.06
Posted: Tue Mar 19, 2013 9:30 am
by mdonath
In version 5.10.05 it was not possible to write this to an Excel97 file:
Code: Select all
try
{
int Lines = 96;
XLSReadWriteII51->Version = xvExcel97;
XLSReadWriteII51->Sheets[0]->Columns->Items[0]->Width = 5000;
TDateTime dt(TDateTime::CurrentDate());
for(int i=0; i<Lines; i++)
XLSReadWriteII51->Sheets[0]->AsDateTime[0][i] = dt + double(i+1)/96.;
::DeleteFile(L"test01.xls");
XLSReadWriteII51->Filename = L"test01.xls";
XLSReadWriteII51->Write();
}
catch(Exception& e)
{
Application->ShowException(&e);
}
That works fine now. But it is not possible to read this file again:
Markus
Re: Problem reading Excel97 files with version 5.10.06
Posted: Tue Mar 19, 2013 10:24 am
by d3nton
I can also reproduce this issue in Delphi.
It throws an 'List index out of bound exception' in unit BIUFF_READII5.pas
procedure TXLSReadII.RREC_COLINFO; line 1252.
Delphi sample code:
var
ExcelFile5 : TXLSReadWriteII5;
begin
ExcelFile5 := TXLSReadWriteII5.Create(nil);
ExcelFile5.Version := xvExcel97;
ExcelFile5.Filename := 'D:\output.xls';
ExcelFile5.Sheets[0].Columns[0].Width := 5000;
ExcelFile5.sheets[0].AsString[0,0] := 'test';
ExcelFile5.Write;
ExcelFile5.Read;
end.
It seems that there is an overflow previously when writing the file in unit
BIFF_WRITEII5.pas procedure TXLSWriteII.WREC_COLINFO; line 1601:
RecCOLINFO(PBuf).FormatIndex := Col.Style.Index - XLS_STYLE_DEFAULT_XF_COUNT;
Col.Style.Index is '0' in the sample case (XLS_STYLE_DEFAULT_XF_COUNT is 1). Since FormatIndex does not accept negative values ( FormatIndex is declared as 'word')
there is an overflow and PRecCOLINFO(PBuf).FormatIndex is saved as 65535. This might be the reason for the 'out of bounds' exception when reading the file.
Re: Problem reading Excel97 files with version 5.10.06
Posted: Thu Mar 21, 2013 9:32 am
by larsa
Hello
FIxed in update 5.10.07
Re: Problem reading Excel97 files with version 5.10.06
Posted: Fri Mar 22, 2013 10:38 am
by d3nton
unfortunately it does not seem to be fixed.
Same error in V 5.10.07.
regards d3nton
Re: Problem reading Excel97 files with version 5.10.06
Posted: Mon Mar 25, 2013 6:50 am
by larsa
Hello
The problem is fixed again in update 5.10.08.
Re: Problem reading Excel97 files with version 5.10.06
Posted: Mon Mar 25, 2013 8:19 am
by mdonath
No, the problem exists in version 5.10.08 too.
Also TXLSTokenizer.EOF is still present.
Markus
Re: Problem reading Excel97 files with version 5.10.06
Posted: Mon Mar 25, 2013 8:25 am
by d3nton
I can confirm this. The problem still exists.
Just tested with my code above.
Re: Problem reading Excel97 files with version 5.10.06
Posted: Tue Mar 26, 2013 11:52 am
by larsa
Hello
Seems that the fixes was lost when I was moving some files. Version 5.10.09 shall be ok.
Re: Problem reading Excel97 files with version 5.10.06
Posted: Tue Mar 26, 2013 2:13 pm
by mdonath
Now it seems that 'AsDateTime' is completely broken:
Code: Select all
XLSReadWriteII51->Sheets[0]->AsDateTime[0][0] = TDateTime::CurrentDateTime();
In the Excel file the value is 00.01.1900 00:00
By the way, 'TXLSTokenizer.EOF' still exists, also in version 5.10.09.
Markus
Re: Problem reading Excel97 files with version 5.10.06
Posted: Tue Mar 26, 2013 2:38 pm
by mdonath
In the meantime I have found out that 'AsDateTime' fails if the double value of the TDateTime value has more than 4 digits after the decimal point.
Markus
Re: Problem reading Excel97 files with version 5.10.06
Posted: Tue Mar 26, 2013 3:44 pm
by larsa
Hello
This was really complicated... Please download the component again. I hope I got it right now...
Re: Problem reading Excel97 files with version 5.10.06
Posted: Tue Mar 26, 2013 4:20 pm
by mdonath
Hello,
It seems to be the same version (with the same problems) as before (5.10.09).
Markus
Re: Problem reading Excel97 files with version 5.10.06
Posted: Wed Mar 27, 2013 6:45 pm
by larsa
Hello
I can't reproduce the problem anymore, so I consider this to be fixed. The version number was hovewer not changed in the last update but it is now, 5.10.10
Re: Problem reading Excel97 files with version 5.10.06
Posted: Wed Mar 27, 2013 8:57 pm
by mdonath
Congratulations! Now all works fine.