How to upload only non-empty rows of Excel spreadsheet using oledb in C#?

前端 未结 4 1955
遥遥无期
遥遥无期 2021-01-02 07:59

I am importing excel sheet to DataTable using oledb connection as below.

private static DataTable UploadExcelSheet(string fileName)
    {
        DataTable u         


        
4条回答
  •  隐瞒了意图╮
    2021-01-02 08:35

    How about filtering the rows after the query has executed using Linq to object:

    var filteredRows = uploadDataTable.Rows.Cast().Where(
      row => row.ItemArray.Any(field => !(field is System.DBNull)));
    

提交回复
热议问题