.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

Workbook.BeforePrintSheet Event

Occurs before printing a workbook.

You need an active license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this event in production code.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v20.1.dll

Declaration

public event BeforePrintSheetEventHandler BeforePrintSheet
Public Event BeforePrintSheet As BeforePrintSheetEventHandler

Event Data

The BeforePrintSheet event's data class is BeforePrintSheetEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
Index Returns the index of the worksheet to be printed.
Name Returns the name of the worksheet to be printed.

Remarks

The BeforePrintSheet event fires for each worksheet being printed or exported to PDF. To cancel the print/export operation, set e.Cancel to true.

The code sample below shows how to cancel printing or exporting to PDF worksheets with drawing objects (shapes, pictures and charts).

static Workbook workbook;
static void Main(string[] args)
{
    workbook = new Workbook();
    workbook.LoadDocument("Documents\\Spreadsheet Book.xls");
    workbook.BeforePrintSheet += Workbook_BeforePrintSheet;
}

private static void Workbook_BeforePrintSheet(object sender, BeforePrintSheetEventArgs e)
{
    if (workbook.Worksheets[e.Name].Shapes.Count != 0) e.Cancel = true;
}

Implements

See Also