jj819430
asked on
Excel Empty Cell Value
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 ""
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 ""
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I meant
if(ExcelString != Convert.ToString(DBNull.Va lue))
{
}
if(ExcelString != Convert.ToString(DBNull.Va
{
}
Can you put more code?
How do you connect to excel? Using COM object or OLEDB?
How do you connect to excel? Using COM object or OLEDB?
ASKER
void ConnectandRead()
{
String sConnectionString = "Provider=Microsoft.Jet.OL EDB.4.0;" + "Data Source=C:\\Files\\" + filename + ";" +"Extended Properties='Excel 8.0; IMEX=1;'";
OleDbConnection objConn = new OleDbConnection(sConnectio nString);
objConn.Open();
OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDatase t1, "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].Cel ls[0].Text
I am trying to figure out what is in ExcelString if the data read from the excel sheet was a null.
{
String sConnectionString = "Provider=Microsoft.Jet.OL
OleDbConnection objConn = new OleDbConnection(sConnectio
objConn.Open();
OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDatase
}
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].Cel
I am trying to figure out what is in ExcelString if the data read from the excel sheet was a null.
ASKER
Nevermind, got it on my own. It was == " " (I guess it changes it to a black space if it is null during the conversions.
ASKER
if (ExcelString != DBNull.Value)
{
}
is not capturing it... it is weird because I would have thought it would be fine.