I am having a function as follows:
public int CreateMyTask()
{
Console.WriteLine("Invoking CreateTask method");
Console.WriteLine("-----------------------------------");
m_taskID = taskClient.CreateTask(m_tInstance);
Console.WriteLine("Task create successfully:ID=" + m_taskID.ToString());
Console.WriteLine("-----------------------------------");
return m_taskID;
}
What I need to do is :-
-
I must check the function whether an exception has occurred. Any exception can occur basically. We are not bothered about what exception has occurred. We simple need to find whether AN exception HAS occurred or not. Let that exception be anything.
-
If an exception has indeed occurred, I must record a word “FAIL” in row 2, cell 10 of my excel sheet (D:\excel.xls) and add the text related to the exception like “Nullreference exception has occurred” or “divide by zero exception has occurred” or any exception that has occurred. The exact text of the exception must be copied to row 2, cell 11
-
If no exception has occurred, then I must record a word “PASS” in row 2, cell 10 of my excel sheet.
Can someone help me to get started on this ? Am quite new to c#. Could so with some inputs.
Make sure to check the existence of your file “D:\excel.xls” and also add the reference to “Microsoft.Office.Interop.Excel”.
Don’t miss to add this to your directives section:
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;