TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Cassie Mod
NA
488
70.1k
string is nog recognized as a valid DateTime
Feb 25 2016 11:34 AM
HI i made the followin class to get dates from an excel file.
file:
col:a col:b col:c
1. X-mas 2015-19-12 2016-03-01
2. carnaval 2016-20-02 2016-28-02
using
System;
using
OfficeOpenXml;
using
System.IO;
namespace
CalviVsTribessCheck.Cmd
{
public
static
class
ExcelFileDataAccess
{
public
static
void
ReadExcelFile(DateTime start)
{
var filePath = @
"c:\code\Tools\Development\RtcMonitoring\RatingTribessCheck.Cmd\Vacations.xlsx"
;
var sheetName =
"vacations"
;
using
(var excelPkg =
new
ExcelPackage())
using
(var stream =
new
FileStream(filePath, FileMode.Open))
{
excelPkg.Load(stream);
ExcelWorksheet oSheet = excelPkg.Workbook.Worksheets[sheetName];
var totalRows = oSheet.Dimension.End.Row;
for
(var i = 1; i <= totalRows; i++)
{
var vacationbegindate = DateTime.Parse((oSheet.Cells[i, 1]).Value.ToString());
var vacationenddate = DateTime.Parse((oSheet.Cells[i, 2]).Value.ToString());
BusinessLogic.CheckVacation(start, vacationbegindate, vacationenddate);
}
}
}
}
}
however i get the following error when converting a cell value to a dateTime:
The string is not recognized as a valid DateTime. Index 0 begins with an unknown word
How can i fix this ???? please provide me with your answer
Reply
Answers (
4
)
Trouble to serialize XML with classes and a list
MDL and C coding. V7 and V8i