Piotr Czajkowski 1 rok pred
rodič
commit
1c9ba798f2

+ 2 - 2
ExcelORM/ExcelORM/ExcelWriter.cs

@@ -25,7 +25,7 @@ public class ExcelWriter
         return ++rowIndex;
     }
 
-    public void Write<T>(IEnumerable<T> values, string? worksheetName, bool append = false) where T : class, new()
+    public void Write<T>(IEnumerable<T> values, string? worksheetName = null, bool append = false) where T : class, new()
     {
         var xlWorksheet = xlWorkbook.Worksheets.FirstOrDefault(x => x.Name.Equals(worksheetName, StringComparison.InvariantCultureIgnoreCase));
         
@@ -36,7 +36,7 @@ public class ExcelWriter
         Write(values, xlWorksheet, append);
     }
 
-    private void Write<T>(IEnumerable<T> values, IXLWorksheet worksheet, bool append = false) where T : class, new()
+    private void Write<T>(IEnumerable<T> values, IXLWorksheet worksheet, bool append) where T : class, new()
     {
         var enumerable = values as T[] ?? values.ToArray();
         if (!enumerable.Any()) return;

+ 3 - 3
ExcelORM/ExcelORMTests/WriterTests.cs

@@ -35,7 +35,7 @@ public class WriterTests
         writer.SaveAs(testFile);
         
         reader = new ExcelReader(testFile);
-        Assert.Equal(5, reader.Read<Test>(worksheetName).Count());
+        Assert.Equal(5, reader.Read<Test>().Count());
         File.Delete(testFile);
     }
     
@@ -46,13 +46,13 @@ public class WriterTests
         testFile = Path.ChangeExtension(testFile, "xlsx");
 
         var writer = new ExcelWriter(testFile);
-        writer.Write(arrayOfThree, null);
+        writer.Write(arrayOfThree);
         writer.SaveAs(testFile);
 
         var reader = new ExcelReader(testFile);
         Assert.Equal(3, reader.Read<Test>().Count());
 
-        writer.Write(listOfTwo, null, true);
+        writer.Write(listOfTwo, append: true);
         writer.SaveAs(testFile);
         
         reader = new ExcelReader(testFile);