TdxSpreadSheetReportDesigner.OnNewDocument Event
Enables you to provide multiple spreadsheet controls as report building destinations.
Declaration
property OnNewDocument: TdxSpreadSheetReportDesignerNewDocumentEvent read; write;
Remarks
This event is fired every time the Report Designer finishes building a previous section of the master-detail report, provided that the Options.ReportMode property is set to rmMultipleDocuments.
The Sender parameter specifies the Report Designer control that contains the master-detail report template.
Pass a new Spreadsheet control (a TdxCustomSpreadSheet descendant instance) in the OnNewDocument event handler as the destination document for building a detail section following the next master dataset row:
procedure TfrmMasterDetail.ReportDesignerNewDocument(Sender: TdxSpreadSheetReportDesigner; var ADestination: TdxCustomSpreadSheet);
var
APreview: TfrmPreview; // A report preview form
APreviewCaptionPrefix: string;
begin
APreview := TfrmPreview.Create(nil); // Create a new preview form
APreviewCaptionPrefix := 'Report Preview';
ADestination := APreview.ssResult; // The preview form class has a TdxSpreadSheet component
ADestination.ClearAll; // Remove all worksheets from the destination Spreadsheet control on a newly created report window
APreview.Caption := APreviewCaptionPrefix + ' : MasterRecordIndex = ' + IntToStr(Sender.DataBinding.DataController.FocusedRowIndex); // Add a master record index to each report preview window
APreview.Show; // Display a new report window
APreview.Left := APreview.Left + Sender.DataBinding.DataController.FocusedRowIndex * 30; // Shift each new report window right by 30 pixels
APreview.Top := APreview.Top + Sender.DataBinding.DataController.FocusedRowIndex * 30; // Shift each new report window down by 30 pixels
end;
As a result, each detail section is displayed in its own Spreadsheet control on multiple forms:
Note
The first report document (whose master record index is 0) in rmMultipleDocuments mode is created as the result of calling the Build procedure, prior to the first OnNewDocument event occurrence.