I have a couple of columns of data in an excel sheet which I have to import to my application.
I do this using -
string strConn;
OleDbDataAdapter oledaExcelInfo;
strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + Server.MapPath(strSavePath + strRepFileName) + ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1\"";
oledaExcelInfo = new OleDbDataAdapter("SELECT * FROM [Book1]", strConn);
dsetExcelInfo = new DataSet();
oledaExcelInfo.Fill(dsetExcelInfo, "CCInfo");
While this imports data successfully, sometimes the data is imported incorrectly i.e. sometimes a number 1234567
could be imported as 1.23E+06
This can be solved if the data in the excel file is '1234567
instead of 1234567
(append the single quotation mark)
I am now trying to manipulate data that I fetch from the excel so that before I import the data I can programmatically append a '
to all the values to prevent the incorrect import.
I even tried using OleDbDataAdapter.Update but I guess this will not help as this happens after the data is imported. Is that correct?
Can I manipulate data so that I import the correct data? How can I do it?