Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:51:02+00:00 2026-06-11T12:51:02+00:00

I have a code reading data from excel spreadsheet and I have gone this

  • 0

I have a code reading data from excel spreadsheet and I have gone this far with some answers on SO

DataTable dt = ds.Tables[0];
dt = dt.AsEnumerable().Where((row, index) => index > 4).CopyToDataTable();
DataTable filteredRows = dt.Rows.Cast<DataRow>().Where(row => row.ItemArray.All(field => !(field is System.DBNull))).CopyToDataTable();

having this

dt.Rows.Cast<DataRow>().Where(row => row.ItemArray.All(field => (field is System.DBNull)))

returns all rows that are empty.

I have also tried Any, it didn’t give the required output

The code above works for where all the fields are not NULL i.e. every columns has a field. This exempt all rows that have 1 column missing but that’s not what I want.

I want to exempt all rows that have all columns empty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:51:03+00:00Added an answer on June 11, 2026 at 12:51 pm

    Just move the NOT (!) out one level. You want the items where “all rows are null” is not true, rather than where “all of the rows are not null” is true.

    DataTable filteredRows = dt.Rows.Cast<DataRow>()
        .Where(row => !row.ItemArray.All(field => field is System.DBNull))
        .CopyToDataTable();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel spreadsheet which contains addresses. I'm reading the data from the
I have a python ndarray temp in some code I'm reading that suffers this:
I am reading data from an Excel 2007 spreadsheet using ADO. Setting up the
I have a VSTO addin and I'm reading data from an Excel worksheet. It
I have the following C# code that reads in data from a datatable (which
I have some code reading a text file and scanning for words between brackets:
How I can start reading from a specific byte? I have following code: try
I am using C to open a file for reading. I have this code
I have this simple code where I am sending http request and reading all
1) I have been working on fetching data from an excel sheet i can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.