Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Excel Empty Cell Value

Posted on 2003-12-04
Medium Priority
Last Modified: 2010-08-05
I am reading in from and excel sheet, and placing into a string.
we shall say
ExcelString = (data from excel).

Does anyone know what the value of ExcelString is if the cell was empty?
I need this for comparison, and it is in a place in the app I can't even have it output it to the screen.
I know it is not "null"
I know it is not an empty string ""
Question by:jj819430
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 18

Accepted Solution

testn earned 2000 total points
ID: 9876710
Again.... try DBNull.Value

Author Comment

ID: 9876827
I am trying to use it in an if statement.

if (ExcelString != DBNull.Value)
is not capturing it... it is weird because I would have thought it would be fine.

Author Comment

ID: 9876844
I meant

if(ExcelString != Convert.ToString(DBNull.Value))
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 18

Expert Comment

ID: 9878877
Can you put more code?

How do you connect to excel? Using COM object or OLEDB?

Author Comment

ID: 9882862
void ConnectandRead()
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\Files\\" + filename + ";" +"Extended Properties='Excel 8.0; IMEX=1;'";
                  OleDbConnection objConn = new OleDbConnection(sConnectionString);


                  OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1, "XLData");


After this reading of the data, I put it in a datagrid for display and editing. I convert each one into string format (by force) in order to work with another neccessary

So I have it as string ExcelString = DataGridExcel.Items[1].Cells[0].Text

I am trying to figure out what is in ExcelString if the data read from the excel sheet was a null.

Author Comment

ID: 9884160
Nevermind, got it on my own. It was == " " (I guess it changes it to a black space if it is null during the conversions.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question