rollno formno citycode firstname lastname fathername gender dob centrecode examdate
53303 1 9 abc xyz pqr m 12/13/1995 9003 07/07/2013
the above data is in excel file.
while (RowIndex <= ShtRange.Rows.Count)
{
ColIndex = 0;
ColFrom = ColFrm;
if (RowIndex > 1)
{
dtExcel.Rows.Add();
while (ColFrom <= ColTo)
{
if ((ShtRange.Cells[RowIndex, ColFrom] as Excel.Range).Value2 != null)
dtExcel.Rows[dtExcel.Rows.Count - 1][ColIndex] = (ShtRange.Cells[RowIndex, ColFrom] as Excel.Range).Value2.ToString(); //error occures here
ColIndex++;
ColFrom++;
}
}
RowIndex++;
dtexcel is datatable
when starting reading value from excel file, then value till gender are inserted into datatable but when it reads dob then error occurs that "string was not recognized as valid datetime. couldnot store <35046> in dob column. Expected type is date time.
plz note dob column in dtexcel is of datetime
what is the error in above code? what is couldnot store <35046> in dob column error? from where this value is coming.
Loading
Iftikar HussainPosted Aug 2, 2013, 7:23 AM
Regards,
Iftikar
sri harPosted Oct 5, 2018, 1:16 AM
Iftikar HussainPosted Aug 2, 2013, 7:39 AM
http://forums.ni.com/t5/LabVIEW/UNABLE-TO-READ-DATE-FORMAT-DD-MM-YY-FROM-EXCEL/td-p/996302
Regards,
Iftikar
nishant ranjanPosted Aug 2, 2013, 7:28 AM
and yes thanks for the solution.
Iftikar HussainPosted Aug 2, 2013, 7:25 AM
Regards,
Iftikar
nishant ranjanPosted Aug 2, 2013, 7:19 AM
DateTime conv = DateTime.FromOADate(d);
dtExcel.Rows[dtExcel.Rows.Count - 1][ColIndex] = CONV;
using the above code i am able to get the right value and store in datatable;
but why we have to do so? why its returning value 35046? why we have to parse into double than convert into date time to get it working? kindly let me know?
nishant ranjanPosted Aug 2, 2013, 6:20 AM
Excel.Application appExl;
Excel.Workbook workbook;
Excel.Worksheet NwSheet;
Excel.Range ShtRange;
appExl = new Excel.ApplicationClass();
int ColFrom = Convert.ToInt32(ExcelInfo.txtColFrm.Text);
int ColFrm = Convert.ToInt32(ExcelInfo.txtColFrm.Text);
int ColTo = Convert.ToInt32(ExcelInfo.txtColTo.Text);
long RowIndex = 1;
int ColIndex=0;
string strSheetName=ExcelInfo.txtSheetName.Text;
i am able to read all value of this row before dob but when it reads dob then its gives that value i.e., 35046
Iftikar HussainPosted Aug 2, 2013, 6:14 AM
Regards,
Iftikar
nishant ranjanPosted Aug 2, 2013, 6:12 AM
Iftikar HussainPosted Aug 2, 2013, 6:07 AM
this
mm/dd/yyyy
and check
Regards,
Iftikar
nishant ranjanPosted Aug 2, 2013, 5:56 AM
in excel value is correct. here its giving wrong value. i dont know from where this value coming from. this value doesnot exist anywhere in excel
Iftikar HussainPosted Aug 2, 2013, 5:52 AM
Regards,
Iftikar
nishant ranjanPosted Aug 2, 2013, 5:49 AM
Iftikar HussainPosted Aug 2, 2013, 5:47 AM
Can you put the break point inside the while loop and check what value it is returning dob column from excel?
Regards,
Iftikar