Skip to content

Accessing HeaderFooter.FirstHeader throws Null reference exception #2088

@chifgeri

Description

@chifgeri

EPPlus usage

Commercial use (I have a commercial license)

Environment

Windows

Epplus version

8.1.0

Spreadsheet application

Excel

Description

After upgrading the version to 8.1.0. The following section throws Null reference exception:

var drawing = worksheet.HeaderFooter.FirstHeader.InsertPicture(fs, ePictureType.Png, PictureAlignment.Left);
drawing.Height = 40;

worksheet.HeaderFooter.FirstHeader.CenteredText = pageTitle;
worksheet.HeaderFooter.FirstFooter.LeftAlignedText = $"{ExcelHeaderFooter.CurrentDate} {ExcelHeaderFooter.CurrentTime}";
worksheet.HeaderFooter.FirstFooter.RightAlignedText = $"Printing: {user.DisplayName} - {ExcelHeaderFooter.PageNumber}/{ExcelHeaderFooter.NumberOfPages}";

Tried access only the FirstHeader, but this also throws an exception:

var fh = worksheet.HeaderFooter.FirstHeader;

Image

It works perfectly in 8.0.8 so currently we rolled back the version.

I think its related to this bug:
#2078

Please, can you check this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions