Delphi XE2. XLSReadWriteII version 5. We are registered owners under Fenestra Technologies.
The issue involves a spreadsheet created by TXLSFile (http://sm-software.com/txlsfile.htm). We used TXLSFile to generate certain spreadsheets in last year's release of our software. This year, we switched to XLSReadWriteII for XLSX support. When our software attempts to load an XLS file created with TXLSFile, we receive the following error (duplicated in minimal test program):
exception class : Exception
exception message : Error on reading record # 187, 0092 Offs: 0000130F List index out of bounds (64).
main thread ($ce4):
008135ae +11ea TestReadWrite.exe BIFF_ReadII5 817 +342 TXLSReadII.LoadFromStream
008279c4 +0070 TestReadWrite.exe BIFF5 585 +8 TBIFF5.LoadFromStream
0082791c +0038 TestReadWrite.exe BIFF5 568 +2 TBIFF5.Read
009091eb +0117 TestReadWrite.exe XLSReadWriteII5 558 +17 TXLSReadWriteII5.LoadFromFile
0090942f +0013 TestReadWrite.exe XLSReadWriteII5 625 +1 TXLSReadWriteII5.Read
00909dd6 +002a TestReadWrite.exe uTestForm 49 +6 TForm1.readSpreadsheetIntoMemory
00909da3 +000f TestReadWrite.exe uTestForm 37 +1 TForm1.Button1Click
The spreadsheet in question loads without any issues in both in Excel 2010 and LibreOffice 4.2.7.2.
If we load the spreadsheet into Excel and Save As to a new file, the new copy loads without any issues. The spreadsheet is test data and could be supplied for debugging purposes if required.
TXc12IndexColorObjs = class(TXLSStyleObjectList)
// jee -- start workaround for bug
private
itsDefaultIndex: integer;
function findDefault: TXc12IndexColorObj;
// jee -- end workaround for bug
protected
...
{ TXc12IndexColorObjs }
...
procedure TXc12IndexColorObjs.Clear;
begin
inherited;
itsDefaultIndex := -1;
SetIsDefault;
end;
constructor TXc12IndexColorObjs.Create;
begin
inherited Create;
itsDefaultIndex := -1;
end;
function TXc12IndexColorObjs.findDefault: TXc12IndexColorObj;
var
i: integer;
begin
if itsDefaultIndex > -1 then
result := TXc12IndexColorObj(inherited Items[itsDefaultIndex])
else if count > 0 then
begin
i := pred(count);
while i > 0 do
begin
if items[i].RGB = 0 then
break;
dec(i);
end;
itsDefaultIndex := i;
result := findDefault;
end
else
result := nil;
end;
function TXc12IndexColorObjs.GetItems(Index: integer): TXc12IndexColorObj;
begin
// jee temporary work around
if (index < count) then
Result := TXc12IndexColorObj(inherited Items[Index])
else
result := findDefault;
if not assigned(result) then
raise Exception.CreateFmt('Error reading color object at position %d. The list of color objects is empty.', [index]);
end;