public static GenericData GetData(IWorkbook workbook, string sheetName, string sourceName, string sourceTwoName, int PrimaryKeyIndex, int ComparisonOneIndex, int ComparisonTwoIndex, int ComparisonThreeIndex, Dictionary <string, SelfComparingGeneric> dataParameter, Boolean one) { string duplicates = ""; string[] attributeNames = new string[3]; string primaryKeyName = ""; ISheet sheet = GetSheet(workbook, sheetName); Dictionary <string, SelfComparingGeneric> data; HashSet <string> keys = new HashSet <string>(); if (dataParameter != null) { data = dataParameter; } else { data = new Dictionary <string, SelfComparingGeneric>(); } SelfComparingGeneric currentItem; for (int i = 0; i < sheet.LastRowNum; i++) { string[] stringArray = new string[3]; string PrimaryKey; if (sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString() != null && sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString() != "") { /*if(i==0) { * if(sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString() != null && sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString() != "") { * primaryKeyName = sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString(); * } * if (sheet.GetRow(i).GetCell(FileOneC).ToString() != null && sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString() != "") { * primaryKeyName = sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString(); * } * continue; * }*/ PrimaryKey = sheet.GetRow(i).GetCell(PrimaryKeyIndex).ToString(); if (data.ContainsKey(PrimaryKey)) { duplicates += sourceName + " contains multiple entries for " + PrimaryKey; } else { keys.Add(PrimaryKey); } if (!data.ContainsKey(PrimaryKey)) { currentItem = new SelfComparingGeneric(PrimaryKey, sourceName, sourceTwoName, 3); } else { currentItem = data[PrimaryKey]; } if (sheet.GetRow(i).GetCell(ComparisonOneIndex).ToString() != null && sheet.GetRow(i).GetCell(ComparisonOneIndex).ToString() != "") { if (one) { currentItem.AddToOne(sheet.GetRow(i).GetCell(ComparisonOneIndex).ToString(), 0); } else { currentItem.AddToTwo(sheet.GetRow(i).GetCell(ComparisonOneIndex).ToString(), 0); } } if (sheet.GetRow(i).GetCell(ComparisonTwoIndex).ToString() != null && sheet.GetRow(i).GetCell(ComparisonTwoIndex).ToString() != "") { if (one) { currentItem.AddToOne(sheet.GetRow(i).GetCell(ComparisonTwoIndex).ToString(), 1); } else { currentItem.AddToTwo(sheet.GetRow(i).GetCell(ComparisonTwoIndex).ToString(), 1); } } if (sheet.GetRow(i).GetCell(ComparisonThreeIndex).ToString() != null && sheet.GetRow(i).GetCell(ComparisonThreeIndex).ToString() != "") { if (one) { currentItem.AddToOne(sheet.GetRow(i).GetCell(ComparisonThreeIndex).ToString(), 2); } else { currentItem.AddToTwo(sheet.GetRow(i).GetCell(ComparisonThreeIndex).ToString(), 2); } } data[PrimaryKey] = currentItem; } } GenericData result = new GenericData(); result.AddDictionary(data); result.SetDuplicates(duplicates); return(result); }