Browse Source

Let's keep the same order

Piotr Czajkowski 5 months ago
parent
commit
c4d7331959
1 changed files with 2 additions and 3 deletions
  1. 2 3
      ExcelORM/ExcelORM/ExcelWriter.cs

+ 2 - 3
ExcelORM/ExcelORM/ExcelWriter.cs

@@ -14,11 +14,10 @@ public class ExcelWriter
         xlWorkbook = File.Exists(path) ? new XLWorkbook(path) : new XLWorkbook();
     }
 
-    private static int GenerateHeader<T>(IXLWorksheet worksheet) where T : class
+    private static int GenerateHeader<T>(IXLWorksheet worksheet, PropertyInfo[] properties) where T : class
     {
         var rowIndex = 1;
         var cellIndex = 1;
-        var properties = typeof(T).GetProperties();
         foreach (var property in properties)
         {
             if (property.Skip()) continue;
@@ -86,7 +85,7 @@ public class ExcelWriter
             mapping = Mapping.MapProperties<T>(headerCells);
             if (mapping == null || mapping.Count == 0) return;
         } else
-            rowIndex = GenerateHeader<T>(worksheet);
+            rowIndex = GenerateHeader<T>(worksheet, properties);
 
         foreach (var value in values)
         {