Questions and answers on how to use XLSReadWriteII 5.
mdonath
Posts: 23 Joined: Fri Oct 05, 2012 11:36 am
Post
by mdonath » Tue Mar 19, 2013 9:30 am
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
d3nton
Posts: 137 Joined: Thu Oct 25, 2012 9:48 am
Post
by d3nton » Tue Mar 19, 2013 10:24 am
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.
larsa
Site Admin
Posts: 926 Joined: Mon Jun 27, 2005 9:30 pm
Post
by larsa » Thu Mar 21, 2013 9:32 am
Hello
FIxed in update 5.10.07
Lars Arvidsson, Axolot Data
d3nton
Posts: 137 Joined: Thu Oct 25, 2012 9:48 am
Post
by d3nton » Fri Mar 22, 2013 10:38 am
unfortunately it does not seem to be fixed.
Same error in V 5.10.07.
regards d3nton
larsa
Site Admin
Posts: 926 Joined: Mon Jun 27, 2005 9:30 pm
Post
by larsa » Mon Mar 25, 2013 6:50 am
Hello
The problem is fixed again in update 5.10.08.
Lars Arvidsson, Axolot Data
mdonath
Posts: 23 Joined: Fri Oct 05, 2012 11:36 am
Post
by mdonath » Mon Mar 25, 2013 8:19 am
No, the problem exists in version 5.10.08 too.
Also TXLSTokenizer.EOF is still present.
Markus
d3nton
Posts: 137 Joined: Thu Oct 25, 2012 9:48 am
Post
by d3nton » Mon Mar 25, 2013 8:25 am
I can confirm this. The problem still exists.
Just tested with my code above.
larsa
Site Admin
Posts: 926 Joined: Mon Jun 27, 2005 9:30 pm
Post
by larsa » Tue Mar 26, 2013 11:52 am
Hello
Seems that the fixes was lost when I was moving some files. Version 5.10.09 shall be ok.
Lars Arvidsson, Axolot Data
mdonath
Posts: 23 Joined: Fri Oct 05, 2012 11:36 am
Post
by mdonath » Tue Mar 26, 2013 2:13 pm
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
mdonath
Posts: 23 Joined: Fri Oct 05, 2012 11:36 am
Post
by mdonath » Tue Mar 26, 2013 2:38 pm
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
larsa
Site Admin
Posts: 926 Joined: Mon Jun 27, 2005 9:30 pm
Post
by larsa » Tue Mar 26, 2013 3:44 pm
Hello
This was really complicated... Please download the component again. I hope I got it right now...
Lars Arvidsson, Axolot Data
mdonath
Posts: 23 Joined: Fri Oct 05, 2012 11:36 am
Post
by mdonath » Tue Mar 26, 2013 4:20 pm
Hello,
It seems to be the same version (with the same problems) as before (5.10.09).
Markus
larsa
Site Admin
Posts: 926 Joined: Mon Jun 27, 2005 9:30 pm
Post
by larsa » Wed Mar 27, 2013 6:45 pm
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
Lars Arvidsson, Axolot Data
mdonath
Posts: 23 Joined: Fri Oct 05, 2012 11:36 am
Post
by mdonath » Wed Mar 27, 2013 8:57 pm
Congratulations! Now all works fine.