Hi,
I created a c# winfrom app to read the Excel and put the data in a datagridview. Somehow, it works for one Excel file, but not for the other one.
Here is the good example. I can read 999.010 in datagridview without any issue.
Here is the bad example. 999.010 is indicated as 999.01. The same issue to 999.020, etc. And 999.028 became 999.028000000001. 
Both Excel files are .xlsx file created in MS Office 365. The cell format is Number, with 3 decimals. No idea why the result is different. Could you please help?
I use this code to convert the spreadsheet to datatable:
public DataTable dtCfgSheet(string FileName, string SheetName)
{
string strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + FileName + ";Extended Properties='Excel 12.0; HDR=YES; IMEX=1'";
OleDbConnection oleConn = new OleDbConnection(strConn);
OleDbCommand oleCmd = new OleDbCommand();
DataTable dtCfg = new DataTable();
oleCmd.Connection = oleConn;
oleCmd.CommandType = CommandType.Text;
oleCmd.CommandText = "SELECT * FROM [" + SheetName + "$]";
OleDbDataAdapter oleDA = new OleDbDataAdapter(oleCmd);
oleDA.Fill(dtCfg);
oleConn.Close();
return dtCfg;
}
And use this code to plot the datatable in the datagridview:
dtCfg = dtCfgSheet(tbxCfgSht.Text, cboxShts.Text);
dgvCfg.DataSource = dtCfg;
Thanks.
[UPDATE]
Well. I found the difference between those two Excel files. In the 'good' one, the few cells on the top of the 3rd column is text. But in the 'bad' one, those cells are numbers. I do have some text cell in it, but they are at the bottom. After I moved those text cells to the top, the issue is resolved. But I still want to know why and what the proper way to do. Thanks.

