* fpspreadsheet: db export: export from beginning of dataset. Some hardening.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3627 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
bigchimp
2014-10-03 16:22:20 +00:00
parent 6f14b93502
commit 91e22cd724

View File

@ -86,6 +86,7 @@ const
resourcestring resourcestring
SFPSDescription = 'Spreadsheet files'; SFPSDescription = 'Spreadsheet files';
SFPSFileMustExist = 'Empty file names are not allowed.';
implementation implementation
@ -116,11 +117,16 @@ end;
procedure TCustomFPSExport.DoBeforeExecute; procedure TCustomFPSExport.DoBeforeExecute;
begin begin
Inherited; Inherited;
if FFileName='' then
Raise EDataExporter.Create(SFPSFileMustExist);
FSpreadsheet:=TsWorkbook.Create; FSpreadsheet:=TsWorkbook.Create;
// For extra performance. Note that virtual mode is not an option // For extra performance. Note that virtual mode is not an option
// due to the data export determining flow of the program. // due to the data export determining flow of the program.
FSpreadsheet.Options:=FSpreadsheet.Options+[boBufStream]; FSpreadsheet.Options:=FSpreadsheet.Options+[boBufStream];
FSheet:=FSpreadsheet.AddWorksheet('1'); FSheet:=FSpreadsheet.AddWorksheet('1');
// todo: look into restoring position after done
if not(Dataset.IsUniDirectional) then
Dataset.First; // needed to export all items
FRow:=0; FRow:=0;
end; end;