Solved

Excel Empty Cell Value

Posted on 2003-12-04
6
1,017 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
ID: 9876710
Again.... try DBNull.Value
0
 
LVL 7

Author Comment

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

Author Comment

by:jj819430
ID: 9876844
I meant

if(ExcelString != Convert.ToString(DBNull.Value))
{
}
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 18

Expert Comment

by:testn
ID: 9878877
Can you put more code?

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

Author Comment

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

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

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 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