Ticket T296045
Visible to All Users

Add a capability to stop exporting data to DataTable after the first empty row

created 9 years ago

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.

Comments (2)
NF NF
Nate Farnsworth 9 years ago

    Yes, it would be really useful. I am looking for this exact functionality right now.
    I'm using MVCxSpreadsheet in case that matters.

    DevExpress Support Team 9 years ago

      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.

      Answers approved by DevExpress Support

      created 9 years ago (modified 9 years ago)

      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.

      Additional information:

      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 Basic
      exporter.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
        Show previous comments (6)

          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?

            DevExpress Support Team 9 years ago

              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.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.