-1

I'm importing an excel file into a DataTable, and then getting the information i need from each subsequent DataRow.

My problem is that when i access a DataRow, on this specific DataTable, some fields contain values, but everything else is just null

Please see attached file

Do you have any idea how can I fix this issue?

Value in excel file

result

2 Answers2

0

Apparently in the answer below, if you give a value of “0” to real null columns the value of a non null column returns as per normal.

DataRow: Select cell value by a given column name

So my guess is add a value of “0” to your column that actually has no value.

dcc[3] = 0; 

Then it’s this as you did.

string XNR_N = dcc[11].toString();

Try that otherwise I think we could do with more information.

Nikos
  • 326
  • 2
  • 4
  • 18
  • Thank you for your support,I try it but not working also i fill the null columns in the excel file but i have the same result the last 2 columns dcc[11] and dcc[12] are null – Aoun Oussama Jul 04 '18 at 13:21
0

the problem is related to IMEX value i changed from 2 to 1 in the connection string :)

string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"";