This is a rarely-used way of loading a workbook, and therefore this bug remained unnoticed. Should be fixed in r6076. If you don't use the trunk version of fpspreadsheet you can fix it easily in your local version: Open fpspreadsheet.pas, find procedure TsWorkbook.ReadFromStream (the second overloaded version). Immediately after "finally" add the line "FReadWriteFlag := rwfNormal;"; the entire procedure should be like this:
procedure TsWorkbook.ReadFromStream(AStream: TStream; AFormatID: TsSpreadFormatID;
APassword: String = ''; AParams: TsStreamParams = []);
var
AReader: TsBasicSpreadReader;
ok: Boolean;
begin
AReader := CreateSpreadReader(self, AFormatID);
try
PrepareBeforeReading;
FReadWriteFlag := rwfRead;
ok := false;
inc(FLockCount);
try
AStream.Position := 0;
AReader.ReadFromStream(AStream, APassword, AParams);
ok := true;
UpdateCaches;
if (boAutoCalc in Options) then
Recalc;
FFormatID := AFormatID;
finally
FReadWriteFlag := rwfNormal; // <---- NEW
dec(FLockCount);
if ok and Assigned(FOnOpenWorkbook) then
FOnOpenWorkbook(self);
end;
finally
AReader.Free;
end;
end;
A comment on your code referring to format sfExcelXML. Are you sure that this is the correct format? Or do you mean then xlsx file format. sfExcelXML is a very rarely xml format introduced by Microsoft during the Office2003 times, xlsx was created later for Office2007, its fpspreadsheet identifier is sfOOXML. sfExcelXML was added to fpspreadsheet for testing its extendability to other formats; currently it is only supported for writing.