I am making another windows form application , but some weird things are happening , first example i have a value 0076464688334 , in my excel sheet i am reading them using..
MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + fileName + "';Extended Properties=Excel 12.0;");
MyConnection.Open();
myCommand.Connection = MyConnection;
DataSet ds = new DataSet();
String qry = "SELECT number FROM [Sheet1$]";
OleDbDataAdapter odp = new OleDbDataAdapter(qry, MyConnection);
odp.Fill(ds);
NO when i have all the values in dataset i loop them n do some thing , but the problem is the value i mentioned above all all those who have zero at front become like .
0076464688334 = 76464688334
I kind on replaces 0 with %0 and in code %0 with 0 and it solved , now another problem is that i have a value it is becoming…
824968717929 = 8.2496871793e+011
These are bar codes and i need exact match , can not find how to solve them , help please :).
Thank you in advance to all..
Additional code:
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i][0].ToString() != "" )
{
googleList.Add(ds.Tables[0].Rows[i][0].ToString().Replace("%0", "0"));
// EbayList.Add(ds.Tables[0].Rows[i][0].ToString());
string tmp = string.Empty;
tmp = ds.Tables[0].Rows[i][0].ToString().Replace("%0","0");
You should change the type of the cell in excel because the values in the cell are transformed to simple numbers.
To do that you can set the Format to text, which will then be mapped to a string with your reader.
Alternatively you can use the COM interfaces to read your spreadsheets or try this one:
ExcelDataReader
if they are in open office format (.XLSX files) you can use
EPP Plus