public void Should_add_an_header_without_configuration() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- ExcelWorksheet worksheet = excelPackage1.GetWorksheet("TEST5"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- worksheet.AddHeader("NewBarcode", "NewQuantity", "NewUpdatedDate"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- worksheet.Dimension.End.Row.Should().Be(5); worksheet.Cells[1, 1, 1, 1].Value.Should().Be("NewBarcode"); worksheet.Cells[1, 2, 1, 2].Value.Should().Be("NewQuantity"); worksheet.Cells[1, 3, 1, 3].Value.Should().Be("NewUpdatedDate"); worksheet.Cells[2, 1, 2, 1].Value.Should().Be("Barcode"); }
public void Should_AddHeader_method_work() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets["TEST5"]; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- worksheet.AddHeader(x => { x.Style.Fill.PatternType = ExcelFillStyle.Solid; x.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(170, 170, 170)); }, "Barcode", "Quantity", "UpdatedDate"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- worksheet.Dimension.End.Row.Should().Be(5); }
public void Should_add_headers() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- ExcelWorksheet worksheet = excelPackage1.GetWorksheet("TEST5"); Color color = Color.AntiqueWhite; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- worksheet.AddHeader(x => x.SetBackgroundColor(color), "NewBarcode", "NewQuantity", "NewUpdatedDate"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- worksheet.Dimension.End.Row.Should().Be(5); worksheet.Cells[1, 1, 1, 1].Value.Should().Be("NewBarcode"); worksheet.Cells[1, 2, 1, 2].Value.Should().Be("NewQuantity"); worksheet.Cells[1, 3, 1, 3].Value.Should().Be("NewUpdatedDate"); worksheet.Cells[1, 1, 1, 1].Style.Fill.BackgroundColor.Rgb.Should().Be($"{color.ToArgb() & 0xFFFFFFFF:X8}"); worksheet.Cells[2, 1, 2, 1].Value.Should().Be("Barcode"); }
/// <summary> /// Inserts a header line to the top of the worksheet /// </summary> /// <param name="worksheet"></param> /// <param name="headerTexts"></param> /// <returns></returns> public static ExcelWorksheet AddHeader(this ExcelWorksheet worksheet, params string[] headerTexts) => worksheet.AddHeader(null, headerTexts);