public string validateExcel(string sourcePath)
 {
     ReadExcel excelFile = new ReadExcel(sourcePath);
     excelFile.OpenSheet("AddUser");
     List<User> users = excelFile.getAddUserList();
     string validatePersonalDetailsLog = excelFile.validatePersonalDetails();
     string validateEntityDetailsLog = excelFile.validateEntityDetails(users);
     string validateConsistencyLog = excelFile.validateHomeEntityConsistency(users);
     if (validatePersonalDetailsLog.Equals(""))
     {
         txtLog.AppendText(Environment.NewLine + "Personal Details Validated..");
     }
     else
     {
         txtLog.AppendText(Environment.NewLine + "Personal Details Validation Failed..");
     }
     Thread.Sleep(200);
     if (validateEntityDetailsLog.Equals(""))
     {
         txtLog.AppendText(Environment.NewLine + "Entity Details Validated..");
     }
     else
     {
         txtLog.AppendText(Environment.NewLine + "Entity Details Validation Failed..");
     }
     Thread.Sleep(200);
     if (validateConsistencyLog.Equals(""))
     {
         txtLog.AppendText(Environment.NewLine + "Data Consistency Validated..");
     }
     else
     {
         txtLog.AppendText(Environment.NewLine + "Inconsistent Data Found..");
     }
     Thread.Sleep(200);
     excelFile.CloseExcel();
     return validatePersonalDetailsLog + validateEntityDetailsLog + validateConsistencyLog;
 }
 private void AddData_Click(object sender, EventArgs e)
 {
     string log = "";
     try
     {
         ReadExcel excelFile = new ReadExcel(sourcePath);
         try
         {
             excelFile.OpenSheet("AddUser");
             List<User> users = new List<User>();
             users = excelFile.getAddUserList();
             string xmlData = "";
             DBConnect dbc = new DBConnect();
             foreach (User user in users)
             {
                 user.xml = Extension.Serialize<User>(user);
                 xmlData += Environment.NewLine + user.xml;
                 string str = "Working for user " + user.userName + ".." + Environment.NewLine;
                 str += Extension.decodeAddUserLog(dbc.addUserFromXml(user));
                 log += str + Environment.NewLine + Environment.NewLine;
                 txtLog.AppendText(Environment.NewLine + str);
                 Thread.Sleep(500);
             }
             Extension.writeStringToPath("xmlData.xml",xmlData);
             Extension.writeStringToPath(this.addUserLog, log);
             excelFile.CloseExcel();
             MessageBox.Show("Operation Complete. Check \"" + addUserLog + "\" file for more details.");
         }
         catch (COMException nre)
         {
             Console.WriteLine(nre.Message.ToString());
             MessageBox.Show("Sheet not found");
             this.sourcePath = "";
         }
     }
     catch (COMException ex)
     {
         MessageBox.Show(ex.Message.ToString().Replace("find", "find File"));
         this.sourcePath = "";
     }
 }