private static bool HandleHeaders(ExcelConvertorSettings settings, IDataRecord reader, ref string[] headers, ref int[] mandatoryColumnsIndexes) { if (reader.FieldCount == 0 || reader.RowHasEmptyCells()) { return(false); } var currentRow = reader.GetCurrentRow().Select(s => JsonCommon.StringCleanup(s.ToString())); var tmpHeader = JsonCommon.ToCamelCase(currentRow).ToArray(); var mci = new List <int>(); for (var i = 0; i < tmpHeader.Count(); i++) { if (settings.MandatoryColumns.Any(s => tmpHeader[i] .Equals(s, StringComparison.InvariantCultureIgnoreCase))) { mci.Add(i); } } mandatoryColumnsIndexes = mci.ToArray(); headers = tmpHeader; return(true); }
private static ExcelConvertorSettings ProcessSettings(ExcelConvertorSettings settings) { if (settings == null) { return(new ExcelConvertorSettings()); } var newMandatoryColumns = new List <string>(); if (settings.MandatoryColumns.Any()) { foreach (var smc in settings.MandatoryColumns) { if (!string.IsNullOrWhiteSpace(smc) && !string.IsNullOrEmpty(smc)) { newMandatoryColumns.Add(smc); } } settings.MandatoryColumns = JsonCommon.ToCamelCase(newMandatoryColumns); } return(settings); }