Reading is superior, but the values ​​go in a different format

I am making another application for Windows forms, but some strange things are happening, the first example I have is 0076464688334, in my excel sheet I read them with.

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 the dataset, I loop them, but the problem is that the value mentioned above, everyone who has a zero in front becomes similar.

  0076464688334 = 76464688334 

I kind on replaces 0 with% 0 and in code% 0 with 0, and he solved, now another problem is that I have a value that it becomes ...

  824968717929 = 8.2496871793e+011 

These are barcodes, and I need an exact match, I can’t find how to solve them, please help :).

Thanks in advance to everyone ..

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"); 
+4
source share
2 answers

You must change the cell type in excel because the values ​​in the cell are converted to prime numbers.

To do this, 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 the following:

ExcelDataReader

if they are in an open office format (.XLSX files), you can use

EPP Plus

+2
source

Check out this link, I also ran into the same problem that you are currently facing,

http://www.codeproject.com/KB/database/GenericParser.aspx

my setup code, which you will find here, which I use to read the file code, is in vb.net, use the conversion utility to convert vb.net to C #.

http://uploading.com/files/7d79e7e2/Excel%2Breading.zip/

If you can’t figure out how to solve it, just comment on my answer and chat in the chat from stackoverflow. I will tell you how you can solve this problem.

If you find your solution from my answer, check it and name it, thanks.

+2
source

All Articles