diff --git a/src/Magicodes.ExporterAndImporter.Excel/ExcelExporter.cs b/src/Magicodes.ExporterAndImporter.Excel/ExcelExporter.cs index 59161eee..b6a06d52 100644 --- a/src/Magicodes.ExporterAndImporter.Excel/ExcelExporter.cs +++ b/src/Magicodes.ExporterAndImporter.Excel/ExcelExporter.cs @@ -384,8 +384,9 @@ private static bool GetExporterHeaderInfoList(out List ex /// /// /// + /// /// - private static bool GetExporterHeaderInfoList(out List exporterHeaderList,DataColumnCollection dataColumns) + private static bool GetExporterHeaderInfoList(out List exporterHeaderList, DataColumnCollection dataColumns) { exporterHeaderList = new List(); var objProperties = typeof(T).GetProperties(); @@ -393,20 +394,22 @@ private static bool GetExporterHeaderInfoList(out List ex return true; int index = 0; - for (var i = 0; i < objProperties.Length; i++) + for (var k = 0; k < dataColumns.Count; k++) { - if (dataColumns.Contains(objProperties[i].Name)) + for (var i = 0; i < objProperties.Length; i++) { - index += 1; - exporterHeaderList.Add(new ExporterHeaderInfo + if (dataColumns[k].ColumnName.Equals(objProperties[i].Name)) { - Index = index, - PropertyName = objProperties[i].Name, - ExporterHeader = - (objProperties[i].GetCustomAttributes(typeof(ExporterHeaderAttribute), true) as - ExporterHeaderAttribute[])?.FirstOrDefault() - }); - + index += 1; + exporterHeaderList.Add(new ExporterHeaderInfo + { + Index = index, + PropertyName = objProperties[i].Name, + ExporterHeader = + (objProperties[i].GetCustomAttributes(typeof(ExporterHeaderAttribute), true) as + ExporterHeaderAttribute[])?.FirstOrDefault() + }); + } } } return false;