public void Should_delete_columns_by_given_header_text() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- ExcelWorksheet worksheet = excelPackage1.GetWorksheet("TEST6"); const string columnName = "Quantity"; ExcelAddressBase valuedDimension = worksheet.GetValuedDimension(); worksheet.ChangeCellValue(2, valuedDimension.End.Column + 1, columnName); worksheet.ChangeCellValue(2, valuedDimension.End.Column + 2, columnName); worksheet.ChangeCellValue(2, valuedDimension.End.Column + 3, columnName); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- worksheet.DeleteColumns(columnName); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- worksheet.GetColumns(2).Any(x => x.Value == columnName).Should().BeFalse(); worksheet.GetValuedDimension().End.Column.Should().Be(2); worksheet.Cells[2, 2, 2, 2].Text.Should().Be("UpdatedDate"); }
public void Should_delete_columns_by_given_header_text() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets["TEST6"]; ExcelAddressBase valuedDimension = worksheet.GetValuedDimension(); worksheet.ChangeCellValue(1, valuedDimension.End.Column + 1, "Quantity"); worksheet.ChangeCellValue(1, valuedDimension.End.Column + 2, "Quantity"); worksheet.ChangeCellValue(1, valuedDimension.End.Column + 3, "Quantity"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- worksheet.DeleteColumns("Quantity"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- worksheet.GetValuedDimension().End.Column.Should().Be(2); worksheet.Cells[1, 2, 1, 2].Text.Should().Be("UpdatedDate"); }