fpspreadsheet: Fix db_import_export example being broken after virtualmode change.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4975 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-07-15 09:23:26 +00:00
parent 0eded6e936
commit 9c83324e90

View File

@ -69,7 +69,7 @@ type
procedure ReadCellDataHandler(Sender: TObject; ARow, ACol: Cardinal; procedure ReadCellDataHandler(Sender: TObject; ARow, ACol: Cardinal;
const ADataCell: PCell); const ADataCell: PCell);
// Virtual mode: for writing: all data for the cells is generated here (out of the .dbf file) // Virtual mode: for writing: all data for the cells is generated here (out of the .dbf file)
procedure WriteCellDataHandler(Sender: TObject; ARow, ACol: Cardinal; procedure WriteCellDataHandler(Sender: TsWorksheet; ARow, ACol: Cardinal;
var AValue: variant; var AStyleCell: PCell); var AValue: variant; var AStyleCell: PCell);
public public
{ public declarations } { public declarations }
@ -491,9 +491,9 @@ begin
// Setup virtual mode to save memory // Setup virtual mode to save memory
// FWorkbook.Options := FWorkbook.Options + [boVirtualMode, boBufStream]; // FWorkbook.Options := FWorkbook.Options + [boVirtualMode, boBufStream];
FWorkbook.Options := FWorkbook.Options + [boVirtualMode]; FWorkbook.Options := FWorkbook.Options + [boVirtualMode];
FWorkbook.OnWriteCellData := @WriteCellDataHandler; worksheet.OnWriteCellData := @WriteCellDataHandler;
FWorkbook.VirtualRowCount := FExportDataset.RecordCount + 1; // +1 for the header line worksheet.VirtualRowCount := FExportDataset.RecordCount + 1; // +1 for the header line
FWorkbook.VirtualColCount := FExportDataset.FieldCount; worksheet.VirtualColCount := FExportDataset.FieldCount;
// Write // Write
DataFileName := ChangeFileExt(DataFileName, FILE_EXT[ DataFileName := ChangeFileExt(DataFileName, FILE_EXT[
@ -599,7 +599,7 @@ end;
{ This is the event handler for exporting a database file to spreadsheet format { This is the event handler for exporting a database file to spreadsheet format
in virtual mode. Data are not written into the worksheet, they exist only in virtual mode. Data are not written into the worksheet, they exist only
temporarily. } temporarily. }
procedure TForm1.WriteCellDataHandler(Sender: TObject; ARow, ACol: Cardinal; procedure TForm1.WriteCellDataHandler(Sender: TsWorksheet; ARow, ACol: Cardinal;
var AValue: variant; var AStyleCell: PCell); var AValue: variant; var AStyleCell: PCell);
begin begin
// Header line: we want to show the field names here. // Header line: we want to show the field names here.
@ -616,7 +616,7 @@ begin
AValue := FExportDataset.Fields[ACol].Value; AValue := FExportDataset.Fields[ACol].Value;
if FExportDataset.Fields[ACol].DataType = ftDate then if FExportDataset.Fields[ACol].DataType = ftDate then
AStyleCell := FDateTemplateCell; AStyleCell := FDateTemplateCell;
if ACol = FWorkbook.VirtualColCount-1 then if ACol = Sender.VirtualColCount-1 then
begin begin
// Move to next record after last field has been written // Move to next record after last field has been written
FExportDataset.Next; FExportDataset.Next;