DataTableExporter.ProcessEmptyRow Event
Occurs when an empty row is encountered during export and the DataTableExportOptions.SkipEmptyRows property is false.
Namespace: DevExpress.Spreadsheet.Export
Assembly: DevExpress.Spreadsheet.v20.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
NuGet Packages: DevExpress.Spreadsheet.Core, DevExpress.WindowsDesktop.Spreadsheet.Core
Declaration
Event Data
The ProcessEmptyRow event's data class is ProcessEmptyRowEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Action | Gets or sets an action to be performed when an empty row is encountered and the DataTableExporter.ProcessEmptyRow event occurs. |
RowIndex | Obtains the index of an empty row. |
The event data class exposes the following methods:
Method | Description |
---|---|
Initialize(Int32) | Initializes the object before passing it to a DataTableExporter.ProcessEmptyRow event handler. |
Remarks
The ProcessEmptyRow event enables you to specify the action performed when the exporter processes an empty row.
Example
using DevExpress.Spreadsheet;
using DevExpress.Spreadsheet.Export;
Worksheet worksheet = spreadsheetControl1.Document.Worksheets.ActiveWorksheet;
CellRange range = worksheet.Selection;
// Determine whether the first row in a range contains headers.
bool rangeHasHeaders = this.barCheckItemHasHeaders1.Checked;
// Determine whether an empty row must stop conversion.
bool stopOnEmptyRow = barCheckItemStopEmptyRow.Checked;
// Create a data table with column names obtained from the first row in a range if it has headers.
// Column data types are obtained from cell value types of cells in the first data row of the worksheet range.
DataTable dataTable = worksheet.CreateDataTable(range, rangeHasHeaders);
// Create the exporter that obtains data from the specified range,
// skips the header row (if required) and populates the previously created data table.
DataTableExporter exporter = worksheet.CreateDataTableExporter(range, dataTable, rangeHasHeaders);
// Handle value conversion errors.
exporter.CellValueConversionError += (sender,args)=> {args.Action = DataTableExporterAction.Continue;};
if (stopOnEmptyRow) {
exporter.Options.SkipEmptyRows = false;
// Handle empty row.
exporter.ProcessEmptyRow += (sender, args) => { args.Action = DataTableExporterAction.Stop; };
}
// Perform the export.
exporter.Export();