private void loadSheets(IDataSourceFile dataSourceFile, IReadOnlyList <string> sheetNames, string filter, string selectedNamingConvention = null) { if (!sheetNames.Any()) { View.DisableConfirmationView(); return; } var sheets = dataSourceFile.DataSheets.GetDataSheetsByName(sheetNames); var dataMappings = dataSourceFile.Format.Parameters.OfType <MetaDataFormatParameter>().Where(p => p.ColumnName != null).Select(md => new MetaDataMappingConverter() { Id = md.MetaDataId, Index = sheetName => md.IsColumn ? dataSourceFile.DataSheets.GetDataSheetByName(sheetName).GetColumnDescription(md.ColumnName).Index : -1 }).ToList(); var mappings = dataMappings.Union ( dataSourceFile.Format.Parameters.OfType <GroupByDataFormatParameter>().Select(md => new MetaDataMappingConverter() { //in case of a duplicate name coming from an excel column used as a grouping by with the same name as a metaData, we add a suffix Id = dataMappings.ExistsById(md.ColumnName) ? md.ColumnName + Constants.ImporterConstants.GroupingBySuffix : md.ColumnName, Index = sheetName => dataSourceFile.DataSheets.GetDataSheetByName(sheetName).GetColumnDescription(md.ColumnName).Index }) ).ToList(); _dataSource.SetMappings(dataSourceFile.Path, mappings); _dataSource.NanSettings = _nanPresenter.Settings; _dataSource.SetDataFormat(_columnMappingPresenter.GetDataFormat()); var errors = _dataSource.AddSheets(sheets, _columnInfos, filter); errors.Add(validateDataSource(_dataSource)); _importerDataPresenter.SetTabMarks(errors, _dataSource.DataSets); if (errors.Any()) { throw new ImporterParsingException(errors); } var keys = new List <string>() { Constants.FILE, Constants.SHEET }; keys.AddRange(_dataSource.GetMappings().Select(m => m.Id)); _confirmationPresenter.SetKeys(keys); View.EnableConfirmationView(); _confirmationPresenter.SetViewingStateToNormal(); _confirmationPresenter.SetNamingConventions(_dataImporterSettings.NamingConventions.ToList(), selectedNamingConvention); }