|
@@ -90,6 +90,30 @@ public class WriterTests
|
|
|
File.Delete(testFile);
|
|
|
}
|
|
|
|
|
|
+ private const string ForAppendWithRubbish = "testFiles/forAppendWithRubbish.xlsx";
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void WriteWithAppendExistingAndRubbish()
|
|
|
+ {
|
|
|
+ var testFile = Path.GetRandomFileName();
|
|
|
+ testFile = Path.ChangeExtension(testFile, "xlsx");
|
|
|
+ File.Copy(ForAppendWithRubbish, testFile);
|
|
|
+
|
|
|
+ uint headerRowIndex = 3;
|
|
|
+ using var writer = new ExcelWriter(testFile);
|
|
|
+ writer.Write(arrayOfThree, append: true, headerRowIndex: headerRowIndex, appendFrom: 7);
|
|
|
+ writer.SaveAs(testFile);
|
|
|
+
|
|
|
+ using var reader = new ExcelReader(testFile);
|
|
|
+ var readArray = reader.Read<Test>(startFrom: headerRowIndex).ToArray();
|
|
|
+ Assert.Equal(6, readArray.Length);
|
|
|
+
|
|
|
+ for (int i = 0; i < arrayOfThree.Length; i++)
|
|
|
+ Assert.Equal(arrayOfThree[i], readArray[i+3]);
|
|
|
+
|
|
|
+ File.Delete(testFile);
|
|
|
+ }
|
|
|
+
|
|
|
private const string ForAppendHeaderFirst = "testFiles/forAppendHeaderFirst.xlsx";
|
|
|
|
|
|
[Fact]
|