Solved

Excel Empty Cell Value

Posted on 2003-12-04
6
1,011 Views
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 ""
 
0
Comment
Question by:jj819430
  • 4
  • 2
6 Comments
 
LVL 18

Accepted Solution

by:
testn earned 500 total points
Comment Utility
Again.... try DBNull.Value
0
 
LVL 7

Author Comment

by:jj819430
Comment Utility
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.
0
 
LVL 7

Author Comment

by:jj819430
Comment Utility
I meant

if(ExcelString != Convert.ToString(DBNull.Value))
{
}
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 18

Expert Comment

by:testn
Comment Utility
Can you put more code?

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

Author Comment

by:jj819430
Comment Utility
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);

                  
                  objConn.Open();

                  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.
0
 
LVL 7

Author Comment

by:jj819430
Comment Utility
Nevermind, got it on my own. It was == " " (I guess it changes it to a black space if it is null during the conversions.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now