The Gembox.Spreadsheet library provides this capability by setting the ExtractDataOptions property to the ExtractDataOptions.StopAtFirstEmptyRow value.
It will be really useful to have the same feature in the DataTableExporter class.
Add a capability to stop exporting data to DataTable after the first empty row
Answers approved by DevExpress Support
We have implemented the functionality described in this ticket. It will be included in our next update(s).
Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.
The DevExpress.Spreadsheet.Export.DataTableExporter.ProcessEmptyRow event is implemented. If the DataTableExportOptions.SkipEmptyRows property is set to false, the event is fired. If the SkipEmptyRows property is true, empty rows are skipped and event does not occur.
The event arguments provide you with the index of an empty row (e.RowIndex) and enable you to specify an action which should be taken when processing an empty row.
To stop the export when the first empty row is encountered, set e.Action to DataTableExporterAction.Stop, as illustrated in the following code snippet:
C#exporter.Options.SkipEmptyRows = true;
exporter.ProcessEmptyRow += exporter_ProcessEmptyRow;
// Perform the export.
exporter.Export();
//...
void exporter_ProcessEmptyRow(object sender, ProcessEmptyRowEventArgs e) {
if(e.RowIndex > 20)
e.Action = DataTableExporterAction.Stop;
else
e.Action = DataTableExporterAction.SkipRow;
}
Visual Basicexporter.Options.SkipEmptyRows = True
AddHandler exporter.ProcessEmptyRow, AddressOf exporter_ProcessEmptyRow
' Perform the export.
exporter.Export()
'...
Private Sub exporter_ProcessEmptyRow(Object sender, ProcessEmptyRowEventArgs e)
If e.RowIndex > 20 Then
e.Action = DataTableExporterAction.Stop
Else
e.Action = DataTableExporterAction.SkipRow
End If
End Sub
- v15.2.4Download Official Update
- v15.1.8Download Official Update
Oleg,
Carelessness on my part. I failed to update ALL of my subscriptions. The ProcessEmptyRowEventArgs instance works fine now.
Also, thank you for the example application. Although my application is more involved, your example shows the basics and is helpful for references.
e.Action = DataTableExporterAction.Skip (as shown above)
or
e.Action = DataTableExporterAction.SkipRow?
Hi Larry,
There is no "Skip" value in the DataTableExporterAction enumeration. I have corrected our initial answer.
If you need to skip an empty row, set the e.Action to the DataTableExporterAction.SkipRow value. If you need to stop exporting data, set the the e.Action to the DataTableExporterAction.Stop value.
Yes, it would be really useful. I am looking for this exact functionality right now.
I'm using MVCxSpreadsheet in case that matters.
Hello Nate,
Our developers will investigate a capability to support this feature in one of future versions of our components. We will update the status of this ticket once we have any results.
Since our DataTableExporter is a cross-platform component, once this feature is introduced, you will be able to use it for the MVC Spreadsheet extension as well.
Please stay tuned to our announcements.