I am using EPPLus to create and format an excel sheet from my data set. I want to set headers on the excel sheet using EPPlus. I could not find a way to do it. I want to set the left header, right header and center header. I have done this using VBA code, but I wan to move away from that. In VBA I would just do
With ActiveSheet.PageSetup
.LeftHeader = ""
.RightHeader =""
.CenterHeader= ""
End With
Help!! Thanks
PS: I am creating a winforms application. I was not sure if that would change anything but just wanted to mention it here. Thanks
I finally figured it out.
It can be done using
workSheet.HeaderFooter.FirstHeader.LeftAlignedText = ""
workSheet.HeaderFooter.FirstHeader.RightAlignedText = ""
workSheet.HeaderFooter.FirstHeader.CenterAlignedText = ""
This sets for the First page.
Changing the FirstHeader
Property to EvenHeader
and OddHeader
sets if for the following pages.
There are a couple of properties differentFirst
and differentOddEven
which set if the pages have different headers. But I was not able to get it to work By setting them to false and just setting one of the headers.
Had to set all three separately.
Hope it is useful Thanks