fpspreadsheet: Fix failure of reading BIFF5 files in BIFFExplorer.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2972 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-04-25 22:17:40 +00:00
parent 7c2851cd98
commit adf4df6ea1
4 changed files with 35 additions and 8 deletions

View File

@ -223,7 +223,7 @@
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Exceptions Count="4">
<Item1>
<Name Value="EAbort"/>
</Item1>
@ -233,6 +233,9 @@
<Item3>
<Name Value="EFOpenError"/>
</Item3>
<Item4>
<Name Value="EStreamError"/>
</Item4>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -366,7 +366,6 @@ object MainForm: TMainForm
object BtnFindNext: TSpeedButton
Left = 240
Height = 22
Hint = 'Find next'
Top = 6
Width = 23
Action = AcFindNext
@ -411,7 +410,6 @@ object MainForm: TMainForm
object BtnFindPrev: TSpeedButton
Left = 216
Height = 22
Hint = 'Find previous'
Top = 6
Width = 23
Action = AcFindPrev
@ -453,10 +451,9 @@ object MainForm: TMainForm
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
end
object BtnCloseFind: TSpeedButton
object SpeedButton3: TSpeedButton
Left = 3
Height = 22
Hint = 'Close "Find" panel'
Top = 6
Width = 23
Action = AcFindClose

View File

@ -757,6 +757,7 @@ end;
procedure TMainForm.LoadFile(const AFileName: String; AFormat: TsSpreadsheetFormat);
var
OLEDocument: TOLEDocument;
streamname: UTF8String;
begin
if MemStream <> nil then
FreeAndNil(MemStream);
@ -773,7 +774,8 @@ begin
// Only one stream is necessary for any number of worksheets
OLEDocument.Stream := MemStream;
OLEStorage.ReadOLEFile(AFileName, OLEDocument, 'Workbook');
if AFormat = sfExcel8 then streamname := 'Workbook' else streamname := 'Book';
OLEStorage.ReadOLEFile(AFileName, OLEDocument, streamname);
// Check if the operation succeded
if MemStream.Size = 0 then
@ -1115,7 +1117,13 @@ end;
procedure TMainForm.UpdateCaption;
begin
Caption := Format('BIFF Explorer - "%s', [IfThen(FFileName <> '', FFileName, 'no file loaded')]);
if FFileName = '' then
Caption := 'BIFF Explorer - (no file loaded)'
else
Caption := Format('BIFF Explorer - "%s [%s]', [
FFileName,
GetFileFormatName(FFormat)
]);
end;

View File

@ -5,12 +5,14 @@ unit beUtils;
interface
uses
Classes, SysUtils, IniFiles, Forms;
Classes, SysUtils, IniFiles, Forms,
fpspreadsheet;
function CreateIni : TCustomIniFile;
procedure ReadFormFromIni(ini: TCustomIniFile; ASection: String; AForm: TCustomForm);
procedure WriteFormToIni(ini: TCustomIniFile; ASection: String; AForm: TCustomForm);
function GetFileFormatName(AFormat: TsSpreadsheetFormat): String;
implementation
@ -62,5 +64,22 @@ begin
end;
end;
function GetFileFormatName(AFormat: TsSpreadsheetFormat): string;
begin
case AFormat of
sfExcel2 : Result := 'BIFF2';
sfExcel3 : Result := 'BIFF3';
sfExcel4 : Result := 'BIFF4';
sfExcel5 : Result := 'BIFF5';
sfExcel8 : Result := 'BIFF8';
sfooxml : Result := 'OOXML';
sfOpenDocument : Result := 'Open Document';
sfCSV : Result := 'CSV';
sfWikiTable_Pipes : Result := 'WikiTable Pipes';
sfWikiTable_WikiMedia : Result := 'WikiTable WikiMedia';
else Result := '-unknown format-';
end;
end;
end.