public void Test_Excel_Test4_AdditionalColumnsFromDataRows( ) { var service = new ExcelFileReaderService( ); SampleDataCreator creator = new SampleDataCreator( ); using (Stream stream = SheetTestHelper.GetStream("SampleDataTests.xlsx")) // IMPORTANT: Ensure TestRowNumbers has the right number of rows { var settings = new DataFileReaderSettings( ); settings.SheetId = SheetTestHelper.GetSheetId("SampleDataTests.xlsx", "Test4"); settings.HeadingRowNumber = 3; settings.FirstDataRowNumber = 4; SampleTable table = creator.CreateSample(stream, settings, service); Assert.That(table, Is.Not.Null); Assert.That(table.Columns, Has.Count.EqualTo(4)); Assert.That(table.Rows, Has.Count.EqualTo(2)); Assert.That(table.Columns [0].ColumnName, Is.EqualTo("A")); Assert.That(table.Columns [0].Name, Is.EqualTo("Heading 1")); Assert.That(table.Columns [1].ColumnName, Is.EqualTo("B")); Assert.That(table.Columns [1].Name, Is.EqualTo("Heading 2")); Assert.That(table.Columns [2].ColumnName, Is.EqualTo("C")); Assert.That(table.Columns [2].Name, Is.EqualTo("C")); Assert.That(table.Columns [3].ColumnName, Is.EqualTo("D")); Assert.That(table.Columns [3].Name, Is.EqualTo("D")); } }
public void Test_Excel_Test2_NoHeadingRow( ) { var service = new ExcelFileReaderService( ); SampleDataCreator creator = new SampleDataCreator( ); using (Stream stream = SheetTestHelper.GetStream("SampleDataTests.xlsx")) // IMPORTANT: Ensure TestRowNumbers has the right number of rows { var settings = new DataFileReaderSettings( ); settings.SheetId = SheetTestHelper.GetSheetId("SampleDataTests.xlsx", "Test2"); settings.HeadingRowNumber = 0; settings.FirstDataRowNumber = 3; SampleTable table = creator.CreateSample(stream, settings, service); Assert.That(table, Is.Not.Null); Assert.That(table.Columns, Has.Count.EqualTo(3)); Assert.That(table.Rows, Has.Count.EqualTo(2)); SampleColumn column = table.Columns [0]; Assert.That(column.ColumnName, Is.EqualTo("A")); Assert.That(column.Name, Is.EqualTo("A")); column = table.Columns [2]; Assert.That(column.ColumnName, Is.EqualTo("C")); Assert.That(column.Name, Is.EqualTo("C")); SampleRow row = table.Rows [0]; Assert.That(row.Values, Has.Count.EqualTo(3)); Assert.That(row.Values [2], Is.EqualTo("3")); } }