Excel.Application excelApp = new Excel.Application();
Excel.Workbook excelBook = excelApp.Workbooks.Open(@"C:\Users\Visual Studio 2015\Projects\AlertNotify\AlertNotifyNew.xlsx");
Excel._Worksheet excelSheet = excelBook.Sheets[1];
Excel.Range excelRange = excelSheet.UsedRange;
int rows = excelRange.Rows.Count;
int cols = excelRange.Columns.Count;
for (int i = 2; i <= rows; i++)
{
Console.WriteLine("\t");
DateTime Cdate = DateTime.Now;
string Cdate1 = Cdate.ToString("dd/MM/yyyy");
if (excelRange.Cells[i, j] != null && excelRange.Cells[i, j].text != null)
{
string exDate = excelRange.Cells[i, 2].text;
string exDate1 = exDate.Trim();
if (exDate1 == Cdate1)
{
string uTime = excelRange.Cells[i, 3].text;
DateTime CTime = DateTime.Now;
string CTime1 = CTime.ToString("HH:mm");
if (uTime == CTime1)
{
Timer t1 = new Timer(onTimerTick,null,0,1000);
}
}
}
}
我想在当前日期和时间与从excel中读取的日期和时间相遇后弹出一个警报,而无需使用任何任务计划程序或Windows服务,即必须通过程序本身来实现。我想在控制台应用程序c#中实现这一点。
请告诉我一些示例代码来实现此目标的可能方法。