Skip to main content

IcxExportBeforeSave.OnBeforeSave(TdxSpreadSheet) Method

Enables you to perform specific actions before the Developer Express control’s content is exported to a file.

Declaration

procedure OnBeforeSave(Sender: TdxSpreadSheet);

Parameters

Name Type
Sender TdxSpreadSheet

Remarks

When implemented, this method is called when the export operation is about to save the internally created workbook containing the exported data to a file. You can access this workbook using the Sender parameter, customize the workbook’s settings and/or update its content to fine-tune export results before the operation proceeds.

The following code example shows how to implement a form (called TfrmMyExportProgress) that implements the IcxExportBeforeSave interface and its OnBeforeSave method to switch the paper size of the active worksheet in the resulting workbook to A4.

uses
   ..., cxExport, dxSpreadSheet;
type
// ...
  TfrmMyExportProgress = class(TForm, IcxExportBeforeSave)
// ...
  private
    // IcxExportBeforeSave
    procedure OnBeforeSave(Sender: TdxSpreadSheet);
  end;
implementation
procedure TfrmMyExportProgress.OnBeforeSave(Sender: TdxSpreadSheet);
begin
  Sender.ActiveSheetAsTable.OptionsPrint.Page.Paper.SizeID := 9;
end;

A TfrmExportProgress object can then be passed as the AHandler parameter to export methods, including ExportGridTo~, cxExportPivotGridTo~, cxExportSchedulerTo~, cxExportTLTo~, and cxExportVGTo~.

In addition to the IcxExportBeforeSave interface, you can implement the IcxExportProgress interface in the same TfrmMyExportProgress form to create a universal handler for export events.

See Also