Last post Jun 08, 2010 07:58 AM by PassHours
Jun 08, 2010 05:06 AM|Roba|LINK
Hi,in my application i have to read from an excel files and check the value of every cell i'm using an OleDb connection to open it and reading but i have this issue if some of the cells in the excel sheet is having this warning when i try to read it returns
could any one give me a clue ....knowing that i can not force the user for not having this warning ...i have to solve this within my code ...any advices ....and plz if anything is not clear ask about
Jun 08, 2010 07:04 AMemail@example.com|LINK
read the excel file and stored in dataset
if your dataset has row
if (if (dsImport.Tables.Rows.Count > 0)
if (String.IsNullOrEmpty(dsImport.Tables.Rows[i]["FirstName"].ToString().Trim()) ||
ScriptManager.RegisterStartupScript(this, this.GetType(), "MyFunction", "alert('There are some empty columns in the file being uploaded. Please correct the imported file.');", true);
you can check empty value like that. this is fully tested
Jun 08, 2010 07:19 AM|Roba|LINK
the thing is not that i want to give him warning about it....i want a way that when i'm reading the excel file it would read the content of the cell and not ignore it...the cell does contain a certain value and is not empty...but the reader is seeing it
as empty because it has the warning 'Number stored as text'
Jun 08, 2010 07:37 AM|PassHours|LINK
I guess you are using the OLEDB provider for reading the excel.
Its a common problem that you are facing.
Go for Interop.Excel.dll and work with the Worksheet, Workbook concept which will solve your probs.
Hope that helps
Jun 08, 2010 07:52 AM|Roba|LINK
please do explain a little further .........you mean i should open my workbook differently.....would you give me some exemple or a link that would helo me :) would appreciate it
Jun 08, 2010 07:58 AM|PassHours|LINK
You can check this link for some idea
Look for the "//Getting Data in Cell" section which shows reading values from excel cell. This will pick the data from that cell irrespective of its type and willl not ignore it as you are facing now.