예제 #1
0
        public static Excel.Worksheet FillInTemplate(Excel.Worksheet sheet, ExigenceDetails exigence, Failure failure, Homologation homologation, int indexRecord)
        {
            #region remove template header
            var    indexHeader   = GetHeaderTemplateIndex(sheet);
            string rangeToHeader = "A1:A" + (indexHeader);
            Console.WriteLine("range header: " + rangeToHeader);
            Excel.Range rangeHeader = sheet.Range[rangeToHeader];
            rangeHeader.EntireRow.Delete(Type.Missing);
            #endregion

            string rangeB_To = null;
            string rangeTo   = "A1:A" + sheet.UsedRange.Rows.Count;
            var    rangeA    = sheet.Range[rangeTo];

            #region Replace column A - Failure_name
            var rowsC1 = GetRowsIndexesByText(sheet.Range["A1"], rangeA, "Failure_name");
            if (rowsC1 != null)
            {
                foreach (var row in rowsC1)
                {
                    sheet.Cells[row, 1] = failure.Chapter;
                }
            }
            #endregion

            #region Replace column F - Failure_name & TdH
            rangeTo = rangeTo.Replace('A', 'F');
            var rowsC6 = GetRowsIndexesByText(sheet.Range["F1"], sheet.Range[rangeTo], "Failure_name");
            if (rowsC6 != null)
            {
                Console.WriteLine("rows count c6: " + rowsC6.Count);
                foreach (var row in rowsC6)
                {
                    sheet.Cells[row, 6] = failure.Chapter;
                }
            }

            rowsC6 = GetRowsIndexesByText(sheet.Range["F1"], sheet.Range[rangeTo], "Read from TdH");
            if (rowsC6 != null)
            {
                Console.WriteLine("rows count c6 tdh: " + rowsC6.Count);
                var rowIncrement = 0;
                foreach (var row in rowsC6)
                {
                    // modify row (if new lines were added/removed)
                    var index = row + rowIncrement;

                    if (homologation == null || homologation.FailingDiagCode == null)   // remove homologation line
                    {
                        Excel.Range rng = sheet.Range["F" + index];
                        rng.EntireRow.Delete(Type.Missing);
                        rowIncrement--;
                        continue;
                    }

                    // fill in homologation line
                    sheet.Cells[index, 6] = homologation.FailingDiagCode_Transformed;
                }
            }
            #endregion

            #region Replace column G - Failure_name, Vbx_wal_1_req, Vbx_wal_2_req, Vbx_lih_typ_4, Vbx_mil_ecu_req, Vbx_mil_flsh_req
            rangeTo = "G1:G" + sheet.UsedRange.Rows.Count;
            var rowsC7 = GetRowsIndexesByText(sheet.Range["G1"], sheet.Range[rangeTo], "Vbx_wal_1_req");
            if (rowsC7 != null)
            {
                foreach (var row in rowsC7)
                {
                    if (sheet.Cells[row, 8].Value != null && Convert.ToString(sheet.Cells[row, 8].Value).Trim() == "Read from Exigence SdF")
                    {
                        if (exigence.G1) //if (exigence.G1.ToUpper() == "YES" || exigence.G1.ToUpper() == "OUI")
                        {
                            sheet.Cells[row, 8] = 1;
                        }
                        else
                        {
                            sheet.Cells[row, 8] = 0;
                        }
                    }
                }
            }

            rowsC7 = GetRowsIndexesByText(sheet.Range["G1"], sheet.Range[rangeTo], "Vbx_wal_2_req");
            if (rowsC7 != null)
            {
                foreach (var row in rowsC7)
                {
                    if (sheet.Cells[row, 8].Value != null && Convert.ToString(sheet.Cells[row, 8].Value).Trim() == "Read from Exigence SdF")
                    {
                        if (exigence.G2) //if (exigence.G2.ToUpper() == "YES" || exigence.G2.ToUpper() == "OUI")
                        {
                            sheet.Cells[row, 8] = 1;
                        }
                        else
                        {
                            sheet.Cells[row, 8] = 0;
                        }
                    }
                }
            }

            rowsC7 = GetRowsIndexesByText(sheet.Range["G1"], sheet.Range[rangeTo], "Vbx_lih_typ_4");
            if (rowsC7 != null)
            {
                foreach (var row in rowsC7)
                {
                    if (sheet.Cells[row, 8].Value != null && Convert.ToString(sheet.Cells[row, 8].Value).Trim() == "Read from Exigence SdF")
                    {
                        if (exigence.GEE) //if(exigence.GEE.ToUpper() == "NON" || exigence.GEE.ToUpper() == "NO")
                        {
                            sheet.Cells[row, 8] = 0;
                        }
                        else
                        {
                            sheet.Cells[row, 8] = 1;
                        }
                    }
                }
            }

            rowsC7 = GetRowsIndexesByText(sheet.Range["G1"], sheet.Range[rangeTo], "Failure_name");
            if (rowsC7 != null)
            {
                foreach (var row in rowsC7)
                {
                    var aux = failure.Chapter.Remove(0, 8);
                    aux = Convert.ToString(sheet.Cells[row, 7].Value).Replace("failure_name", aux);

                    sheet.Cells[row, 7] = aux;
                }
            }

            rowsC7 = GetRowsIndexesByText(sheet.Range["G1"], sheet.Range[rangeTo], "Vbx_mil_ecu_req");
            if (rowsC7 != null)
            {
                Console.WriteLine("rows count c7 Vbx_mil_ecu_req: " + rowsC7.Count);
                var rowIncrement = 0;
                foreach (var row in rowsC7)
                {
                    // modify row (if new lines were added/removed)
                    var index = row + rowIncrement;

                    if (homologation == null || homologation.FailingDiagCode == null)   // remove homologation line
                    {
                        Excel.Range rng = sheet.Range["G" + index];
                        rng.EntireRow.Delete(Type.Missing);
                        rowIncrement--;
                        continue;
                    }

                    // fill in homologation line
                    if (homologation.MIL.ToUpper().Trim() == "YES" || homologation.MIL.ToUpper().Trim() == "OUI")
                    {
                        sheet.Cells[index, 8] = 1;
                    }
                    else
                    {
                        sheet.Cells[index, 8] = 0;
                    }
                }
            }

            rangeTo = "G1:G" + sheet.UsedRange.Rows.Count;
            rowsC7  = GetRowsIndexesByText(sheet.Range["G1"], sheet.Range[rangeTo], "Vbx_mil_flsh_req");
            if (rowsC7 != null)
            {
                Console.WriteLine("rows count c7 Vbx_mil_flsh_req: " + rowsC7.Count);
                var rowIncrement = 0;
                foreach (var row in rowsC7)
                {
                    // modify row (if new lines were added/removed)
                    var index = row + rowIncrement;

                    if (homologation == null || homologation.FailingDiagCode == null)   // remove homologation line
                    {
                        Excel.Range rng = sheet.Range["G" + index];
                        rng.EntireRow.Delete(Type.Missing);
                        rowIncrement--;
                        continue;
                    }

                    // fill in homologation line
                    if (homologation.MIL.ToUpper().Trim().Contains("CLIGNOTANT") || homologation.MIL.ToUpper().Trim().Contains("FLASHING"))
                    {
                        sheet.Cells[index, 8] = 1;
                    }
                    else
                    {
                        sheet.Cells[index, 8] = 0;
                    }
                }
            }
            #endregion

            #region Replace column H - Failure_name

            /*rangeTo = "H1:H" + sheet.UsedRange.Rows.Count;
             * //rangeTo = rangeTo.Replace('G', 'H');
             * var rowsC8 = GetRowsIndexesByText(sheet.Range["H1"], sheet.Range[rangeTo], "failure_name");
             * if (rowsC8 != null)
             * {
             *  foreach (var row in rowsC8)
             *  {
             *      sheet.Cells[row, 8] = failure.Chapter.Remove(0, 8);
             *  }
             * }*/
            #endregion

            #region Replace column C - CheckDegradationMode
            //rangeTo = rangeTo.Replace('H', 'C');
            rangeTo = "C1:C" + sheet.UsedRange.Rows.Count;
            var rowsC3 = GetRowsIndexesByText(sheet.Range["C1"], sheet.Range[rangeTo], "CheckDegradationMode");
            if (rowsC3 != null)
            {
                if (rowsC3.Count > 0)
                {
                    rangeB_To = "B1:B" + rowsC3[0];
                }

                var rowIncrement = 0;
                foreach (var row in rowsC3)
                {
                    // increment row (if new lines were added)
                    var index = row + rowIncrement;

                    if (exigence.DegradationMode.Count == 1 && exigence.DegradationMode[0] == ConfigurationManager.AppSettings["InputFile1_NoDegradationMode"])
                    {
                        Excel.Range rng = sheet.Range["C" + index];
                        rng.EntireRow.Delete(Type.Missing);
                        rowIncrement--;
                        continue;
                    }

                    rowIncrement = exigence.DegradationMode.Count - 1;
                    // insert 'n-1' new degradation modes lines
                    for (int i = 0; i < rowIncrement; i++)
                    {
                        sheet.Rows[index + 1].Insert();
                    }

                    // copy data to new lines
                    Excel.Range from = sheet.Range["C" + index].EntireRow;
                    Excel.Range to   = sheet.Range["C" + index + ":C" + (index + rowIncrement)].EntireRow;
                    from.Copy(to);

                    for (int j = 0; j < rowIncrement + 1; j++)
                    {
                        sheet.Cells[index + j, 6] = exigence.DegradationMode[j];
                    }
                }
            }
            #endregion

            #region Replace column B - SetUp initial conditions, Check activation of diag before failure, Steps to create & remove the failure

            #region Replace 'SetUp initial conditions' - sheet InitialConditions
            rangeTo = "B1:B" + sheet.UsedRange.Rows.Count;
            var rowsC2 = GetRowsIndexesByText(sheet.Range["B1"], sheet.Range[rangeTo], "SetUp initial conditions");
            if (rowsC2 != null)
            {
                var rowIncrement = 0;
                foreach (var row in rowsC2)
                {
                    // increment row (if new lines were added)
                    var index = row + rowIncrement;

                    // number of new rows to be inserted
                    rowIncrement = failure.FailureDetails_InitialConditions.Count - 1;

                    // insert 'n-1' new failures procs lines
                    for (int i = 0; i < rowIncrement; i++)
                    {
                        sheet.Rows[index + 1].Insert();
                    }

                    // copy data to new lines
                    Excel.Range from = sheet.Range["B" + index].EntireRow;
                    Excel.Range to   = sheet.Range["B" + index + ":B" + (index + rowIncrement)].EntireRow;
                    from.Copy(to);

                    for (int j = 0; j < rowIncrement + 1; j++)
                    {
                        sheet.Cells[index + j, 2] = failure.FailureDetails_InitialConditions[j].ToRealize;
                        sheet.Cells[index + j, 3] = failure.FailureDetails_InitialConditions[j].Step;
                        sheet.Cells[index + j, 4] = failure.FailureDetails_InitialConditions[j].CANFrame;
                        sheet.Cells[index + j, 5] = failure.FailureDetails_InitialConditions[j].CANMessage;
                        sheet.Cells[index + j, 6] = failure.FailureDetails_InitialConditions[j].ValueToBeGiven;
                        sheet.Cells[index + j, 7] = failure.FailureDetails_InitialConditions[j].VariableToCheck;
                        sheet.Cells[index + j, 8] = failure.FailureDetails_InitialConditions[j].ValueToBeChecked;
                    }
                }
            }
            #endregion

            // replace Check activation of diag before failure - sheet DiagEna
            rangeTo = "B1:B" + sheet.UsedRange.Rows.Count;

            rowsC2 = GetRowsIndexesByText(sheet.Range["B1"], sheet.Range[rangeTo], "Check activation of diag before failure");
            if (rowsC2 != null)
            {
                var rowIncrement = 0;
                foreach (var row in rowsC2)
                {
                    // increment row (if new lines were added)
                    var index = row + rowIncrement;

                    // number of new rows to be inserted
                    rowIncrement = failure.FailureDetails_DiagEna.Count - 1;

                    // insert 'n-1' new failures procs lines
                    for (int i = 0; i < rowIncrement; i++)
                    {
                        sheet.Rows[index + 1].Insert();
                    }

                    // copy data to new lines
                    Excel.Range from = sheet.Range["B" + index].EntireRow;
                    Excel.Range to   = sheet.Range["B" + index + ":B" + (index + rowIncrement)].EntireRow;
                    from.Copy(to);

                    for (int j = 0; j < rowIncrement + 1; j++)
                    {
                        sheet.Cells[index + j, 2] = failure.FailureDetails_DiagEna[j].ToRealize;
                        sheet.Cells[index + j, 3] = failure.FailureDetails_DiagEna[j].Step;
                        sheet.Cells[index + j, 4] = failure.FailureDetails_DiagEna[j].CANFrame;
                        sheet.Cells[index + j, 5] = failure.FailureDetails_DiagEna[j].CANMessage;
                        sheet.Cells[index + j, 6] = failure.FailureDetails_DiagEna[j].ValueToBeGiven;
                        sheet.Cells[index + j, 7] = failure.FailureDetails_DiagEna[j].VariableToCheck;
                        sheet.Cells[index + j, 8] = failure.FailureDetails_DiagEna[j].ValueToBeChecked;
                    }
                }
            }

            rangeTo = "B1:B" + sheet.UsedRange.Rows.Count;
            rowsC2  = GetRowsIndexesByText(sheet.Range["B1"], sheet.Range[rangeTo], "Steps to create the failure");
            if (rowsC2 != null)
            {
                var rowIncrement = 0;
                foreach (var row in rowsC2)
                {
                    // increment row (if new lines were added)
                    var index = row + rowIncrement;

                    // number of new rows to be inserted
                    rowIncrement = failure.FailureDetails_Activate.Count - 1;

                    // insert 'n-1' new failures procs lines
                    for (int i = 0; i < rowIncrement; i++)
                    {
                        sheet.Rows[index + 1].Insert();
                    }

                    // copy data to new lines
                    Excel.Range from = sheet.Range["B" + index].EntireRow;
                    Excel.Range to   = sheet.Range["B" + index + ":B" + (index + rowIncrement)].EntireRow;
                    from.Copy(to);

                    for (int j = 0; j < rowIncrement + 1; j++)
                    {
                        sheet.Cells[index + j, 2] = failure.FailureDetails_Activate[j].ToRealize;
                        sheet.Cells[index + j, 3] = failure.FailureDetails_Activate[j].Step;
                        sheet.Cells[index + j, 4] = failure.FailureDetails_Activate[j].CANFrame;
                        sheet.Cells[index + j, 5] = failure.FailureDetails_Activate[j].CANMessage;
                        sheet.Cells[index + j, 6] = failure.FailureDetails_Activate[j].ValueToBeGiven;
                        sheet.Cells[index + j, 7] = failure.FailureDetails_Activate[j].VariableToCheck;
                        sheet.Cells[index + j, 8] = failure.FailureDetails_Activate[j].ValueToBeChecked;
                    }
                }
            }

            // replace steps to remove the failure - sheet deactivate
            rangeTo = "B1:B" + sheet.UsedRange.Rows.Count;
            rowsC2  = GetRowsIndexesByText(sheet.Range["B1"], sheet.Range[rangeTo], "Steps to remove the failure");
            if (rowsC2 != null)
            {
                var rowIncrement = 0;
                foreach (var row in rowsC2)
                {
                    // increment row (if new lines were added)
                    var index = row + rowIncrement;

                    // number of new rows to be inserted
                    rowIncrement = failure.FailureDetails_Deactivate.Count - 1;

                    // insert 'n-1' new failures procs lines
                    for (int i = 0; i < rowIncrement; i++)
                    {
                        sheet.Rows[index + 1].Insert();
                    }

                    // copy data to new lines
                    Excel.Range from = sheet.Range["B" + index].EntireRow;
                    Excel.Range to   = sheet.Range["B" + index + ":B" + (index + rowIncrement)].EntireRow;
                    from.Copy(to);

                    for (int j = 0; j < rowIncrement + 1; j++)
                    {
                        sheet.Cells[index + j, 2] = failure.FailureDetails_Deactivate[j].ToRealize;
                        sheet.Cells[index + j, 3] = failure.FailureDetails_Deactivate[j].Step;
                        sheet.Cells[index + j, 4] = failure.FailureDetails_Deactivate[j].CANFrame;
                        sheet.Cells[index + j, 5] = failure.FailureDetails_Deactivate[j].CANMessage;
                        sheet.Cells[index + j, 6] = failure.FailureDetails_Deactivate[j].ValueToBeGiven;
                        sheet.Cells[index + j, 7] = failure.FailureDetails_Deactivate[j].VariableToCheck;
                        sheet.Cells[index + j, 8] = failure.FailureDetails_Deactivate[j].ValueToBeChecked;
                    }
                }
            }

            // if tdh null - remove 'Check increase of counter of driving cycles' row

            /*rangeTo = "B1:B" + sheet.UsedRange.Rows.Count;
             * rowsC2 = GetRowsIndexesByText(sheet.Range["B1"], sheet.Range[rangeTo], "Check increase of counter of driving cycles");
             * if (rowsC2 != null)
             * {
             *  var rowIncrement = 0;
             *  foreach (var row in rowsC2)
             *  {
             *      // modify row (if new lines were added/removed)
             *      var index = row + rowIncrement;
             *
             *      if (homologation == null || homologation.FailingDiagCode == null)   // remove homologation line
             *      {
             *          Excel.Range rng = sheet.Range["B" + index];
             *          rng.EntireRow.Delete(Type.Missing);
             *          rowIncrement--;
             *          continue;
             *      }
             *  }
             * }*/
            #endregion

            // merge cells in column A
            rangeA.Merge();
            rangeA.Interior.Color = indexRecord % 2 == 0 ? ColorTranslator.ToOle(Color.FromArgb(151, 157, 163)) : ColorTranslator.ToOle(Color.FromArgb(227, 159, 222));

            #region merge cells in column B
            try
            {
                var rowsNb     = sheet.UsedRange.Rows.Count;
                var rangeStart = 1;
                var rangeEnd   = 1;
                var lastValue  = string.Empty;
                var newValue   = string.Empty;

                for (int i = 1; i <= rowsNb; i++)
                {
                    newValue = Convert.ToString(sheet.Cells[i, 2].Value);
                    if (lastValue == newValue && i != rowsNb)
                    {
                        rangeEnd = i;
                    }
                    else
                    {
                        // if last line
                        if (i == rowsNb && lastValue == newValue)
                        {
                            rangeEnd = i;
                        }

                        if (rangeEnd > rangeStart)
                        {
                            var range = "B" + rangeStart + ":B" + rangeEnd;
                            sheet.Range[range].Merge();
                        }
                        lastValue  = newValue;
                        rangeStart = i;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex, "Merge on column B failed");
            }
            #endregion

            return(sheet);
        }
예제 #2
0
 public static void ProcessFailure(Microsoft.Office.Interop.Excel.Application excelApplication, string templateFilePath, string outputFilePath, ExigenceDetails exigence, Failure failure, Homologation homologation, int indexRecordProcessed)
 {
     ExcelUtils.WriteFailureDataToExcel(excelApplication, templateFilePath, outputFilePath, exigence, failure, homologation, indexRecordProcessed);
 }
예제 #3
0
        public static void WriteFailureDataToExcel(Excel.Application excelApplication, string templateFilePath, string fileTarget, ExigenceDetails exigence, Failure failure, Homologation homologation, int indexRecord)
        {
            try
            {
                Excel.Workbook  srcworkBook  = excelApplication.Workbooks.Open(templateFilePath);
                Excel.Worksheet srcworkSheet = srcworkBook.Worksheets.get_Item(1);

                // modify template
                FillInTemplate(srcworkSheet, exigence, failure, homologation, indexRecord);

                Excel.Workbook  destworkBook  = excelApplication.Workbooks.Open(fileTarget, 0, false);
                Excel.Worksheet destworkSheet = destworkBook.Worksheets.get_Item(1);

                // determine rangeTo
                int sourceLinesNb = srcworkSheet.UsedRange.Rows.Count;
                int lastRow       = destworkSheet.UsedRange.Rows.Count;
                //if (lastRow < 10)
                //lastRow += 1;

                string rangeTo = "A" + (lastRow + 1) + ":H" + (lastRow + 1 + sourceLinesNb); //(lastRow + 36);
                Console.WriteLine("rangeTo -> " + rangeTo);

                Excel.Range from = srcworkSheet.UsedRange;
                Excel.Range to   = destworkSheet.Range[rangeTo];

                // if you use 2 instances of excel, this will not work
                from.Copy(to);

                destworkBook.SaveAs(fileTarget);

                destworkBook.Close(true, null, null);
                srcworkBook.Close(false, null, null);
            }
            catch (Exception ex)
            {
                Logger.Log("Error in processing the exigence: " + exigence.FailureName + ". Details: " + ex.Message + " -- " + ex.StackTrace);
            }
        }
예제 #4
0
        public static Failure GetFailureByName(string name, string sheetActivate, string sheetDeactivate, string sheetDiagEna, string sheetInitialConditions)
        {
            Failure result = null;

            try
            {
                result = new Failure(name);
                var filePath                             = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + ConfigurationManager.AppSettings["InputFile2_Name"];
                var rowsFailureDetails                   = ExcelUtils.GetRowsByColumnIndexAndCellValue(filePath, sheetActivate, 0, name);
                var rowsFailureDetails_Deactivate        = ExcelUtils.GetRowsByColumnIndexAndCellValue(filePath, sheetDeactivate, 0, name);
                var rowsFailureDetails_DiagEna           = ExcelUtils.GetRowsByColumnIndexAndCellValue(filePath, sheetDiagEna, 0, name);
                var rowsFailureDetails_InitialConditions = ExcelUtils.GetRowsByColumnIndexAndCellValue(filePath, sheetInitialConditions, 0, name);

                #region rowsFailureDetails processing
                if (rowsFailureDetails != null && rowsFailureDetails.Count > 0)
                {
                    foreach (var row in rowsFailureDetails)
                    {
                        var detail = new FailureDetail();
                        detail.ToRealize = row.Cells[1].CellType == NPOI.SS.UserModel.CellType.String ? row.Cells[1].StringCellValue :
                                           row.Cells[1].CellType == NPOI.SS.UserModel.CellType.Numeric ? row.Cells[1].NumericCellValue.ToString() : "";

                        detail.Step = row.Cells[2].CellType == NPOI.SS.UserModel.CellType.String ? row.Cells[2].StringCellValue :
                                      row.Cells[2].CellType == NPOI.SS.UserModel.CellType.Numeric ? row.Cells[2].NumericCellValue.ToString() : "";

                        detail.CANFrame = row.Cells[3].CellType == NPOI.SS.UserModel.CellType.String ? row.Cells[3].StringCellValue :
                                          row.Cells[3].CellType == NPOI.SS.UserModel.CellType.Numeric ? row.Cells[3].NumericCellValue.ToString() : "";

                        detail.CANMessage = row.Cells[4].CellType == NPOI.SS.UserModel.CellType.String ? row.Cells[4].StringCellValue :
                                            row.Cells[4].CellType == NPOI.SS.UserModel.CellType.Numeric ? row.Cells[4].NumericCellValue.ToString() : "";

                        detail.ValueToBeGiven = row.Cells[5].CellType == NPOI.SS.UserModel.CellType.String ? row.Cells[5].StringCellValue :
                                                row.Cells[5].CellType == NPOI.SS.UserModel.CellType.Numeric ? row.Cells[5].NumericCellValue.ToString() : "";

                        detail.VariableToCheck = row.Cells[6].CellType == NPOI.SS.UserModel.CellType.String ? row.Cells[6].StringCellValue :
                                                 row.Cells[6].CellType == NPOI.SS.UserModel.CellType.Numeric ? row.Cells[6].NumericCellValue.ToString() : "";

                        detail.ValueToBeChecked = row.Cells[7].CellType == NPOI.SS.UserModel.CellType.String ? row.Cells[7].StringCellValue :
                                                  row.Cells[7].CellType == NPOI.SS.UserModel.CellType.Numeric ? row.Cells[7].NumericCellValue.ToString() : "";

                        //add detail to parent
                        result.FailureDetails_Activate.Add(detail);
                    }
                }
                #endregion

                #region rowsFailureDetails_Deactivate processing
                if (rowsFailureDetails_Deactivate != null && rowsFailureDetails_Deactivate.Count > 0)
                {
                    foreach (var row in rowsFailureDetails_Deactivate)
                    {
                        var detail = new FailureDetail();
                        detail.ToRealize = row.Cells[1].CellType == CellType.String ? row.Cells[1].StringCellValue :
                                           row.Cells[1].CellType == CellType.Numeric ? row.Cells[1].NumericCellValue.ToString() : "";

                        detail.Step = row.Cells[2].CellType == CellType.String ? row.Cells[2].StringCellValue :
                                      row.Cells[2].CellType == CellType.Numeric ? row.Cells[2].NumericCellValue.ToString() : "";

                        detail.CANFrame = row.Cells[3].CellType == CellType.String ? row.Cells[3].StringCellValue :
                                          row.Cells[3].CellType == CellType.Numeric ? row.Cells[3].NumericCellValue.ToString() : "";

                        detail.CANMessage = row.Cells[4].CellType == CellType.String ? row.Cells[4].StringCellValue :
                                            row.Cells[4].CellType == CellType.Numeric ? row.Cells[4].NumericCellValue.ToString() : "";

                        detail.ValueToBeGiven = row.Cells[5].CellType == CellType.String ? row.Cells[5].StringCellValue :
                                                row.Cells[5].CellType == CellType.Numeric ? row.Cells[5].NumericCellValue.ToString() : "";

                        detail.VariableToCheck = row.Cells[6].CellType == CellType.String ? row.Cells[6].StringCellValue :
                                                 row.Cells[6].CellType == CellType.Numeric ? row.Cells[6].NumericCellValue.ToString() : "";

                        detail.ValueToBeChecked = row.Cells[7].CellType == CellType.String ? row.Cells[7].StringCellValue :
                                                  row.Cells[7].CellType == CellType.Numeric ? row.Cells[7].NumericCellValue.ToString() : "";

                        //add detail to parent
                        result.FailureDetails_Deactivate.Add(detail);
                    }
                }
                #endregion

                #region rowsFailureDetails_DiagEna processing
                if (rowsFailureDetails_DiagEna != null && rowsFailureDetails_DiagEna.Count > 0)
                {
                    foreach (var row in rowsFailureDetails_DiagEna)
                    {
                        var detail = new FailureDetail();
                        detail.ToRealize = row.Cells[1].CellType == CellType.String ? row.Cells[1].StringCellValue :
                                           row.Cells[1].CellType == CellType.Numeric ? row.Cells[1].NumericCellValue.ToString() : "";

                        detail.Step = row.Cells[2].CellType == CellType.String ? row.Cells[2].StringCellValue :
                                      row.Cells[2].CellType == CellType.Numeric ? row.Cells[2].NumericCellValue.ToString() : "";

                        detail.CANFrame = row.Cells[3].CellType == CellType.String ? row.Cells[3].StringCellValue :
                                          row.Cells[3].CellType == CellType.Numeric ? row.Cells[3].NumericCellValue.ToString() : "";

                        detail.CANMessage = row.Cells[4].CellType == CellType.String ? row.Cells[4].StringCellValue :
                                            row.Cells[4].CellType == CellType.Numeric ? row.Cells[4].NumericCellValue.ToString() : "";

                        detail.ValueToBeGiven = row.Cells[5].CellType == CellType.String ? row.Cells[5].StringCellValue :
                                                row.Cells[5].CellType == CellType.Numeric ? row.Cells[5].NumericCellValue.ToString() : "";

                        detail.VariableToCheck = row.Cells[6].CellType == CellType.String ? row.Cells[6].StringCellValue :
                                                 row.Cells[6].CellType == CellType.Numeric ? row.Cells[6].NumericCellValue.ToString() : "";

                        detail.ValueToBeChecked = row.Cells[7].CellType == CellType.String ? row.Cells[7].StringCellValue :
                                                  row.Cells[7].CellType == CellType.Numeric ? row.Cells[7].NumericCellValue.ToString() :
                                                  row.Cells[7].CellType == CellType.Boolean ? row.Cells[7].BooleanCellValue.ToString() : "";

                        //add detail to parent
                        result.FailureDetails_DiagEna.Add(detail);
                    }
                }
                #endregion

                #region rowsFailureDetails_InitialConditions processing
                if (rowsFailureDetails_InitialConditions != null && rowsFailureDetails_InitialConditions.Count > 0)
                {
                    foreach (var row in rowsFailureDetails_InitialConditions)
                    {
                        var detail = new FailureDetail();
                        detail.ToRealize = row.Cells[1].CellType == CellType.String ? row.Cells[1].StringCellValue :
                                           row.Cells[1].CellType == CellType.Numeric ? row.Cells[1].NumericCellValue.ToString() : "";

                        detail.Step = row.Cells[2].CellType == CellType.String ? row.Cells[2].StringCellValue :
                                      row.Cells[2].CellType == CellType.Numeric ? row.Cells[2].NumericCellValue.ToString() : "";

                        detail.CANFrame = row.Cells[3].CellType == CellType.String ? row.Cells[3].StringCellValue :
                                          row.Cells[3].CellType == CellType.Numeric ? row.Cells[3].NumericCellValue.ToString() : "";

                        detail.CANMessage = row.Cells[4].CellType == CellType.String ? row.Cells[4].StringCellValue :
                                            row.Cells[4].CellType == CellType.Numeric ? row.Cells[4].NumericCellValue.ToString() : "";

                        detail.ValueToBeGiven = row.Cells[5].CellType == CellType.String ? row.Cells[5].StringCellValue :
                                                row.Cells[5].CellType == CellType.Numeric ? row.Cells[5].NumericCellValue.ToString() : "";

                        detail.VariableToCheck = row.Cells[6].CellType == CellType.String ? row.Cells[6].StringCellValue :
                                                 row.Cells[6].CellType == CellType.Numeric ? row.Cells[6].NumericCellValue.ToString() : "";

                        detail.ValueToBeChecked = row.Cells[7].CellType == CellType.String ? row.Cells[7].StringCellValue :
                                                  row.Cells[7].CellType == CellType.Numeric ? row.Cells[7].NumericCellValue.ToString() :
                                                  row.Cells[7].CellType == CellType.Boolean ? row.Cells[7].BooleanCellValue.ToString() : "";

                        //add detail to parent
                        result.FailureDetails_InitialConditions.Add(detail);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                Logger.Log(ex, string.Format("Error reading failure '{0}' details from file '{1}'.", name, ConfigurationManager.AppSettings["InputFile2_Name"]));
            }

            return(result);
        }