Skip to content

912227 - Modify Header and Footer Page Setup Option #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@ static void Main(string[] args)
//Adding values in worksheet
worksheet.Range["A1:A600"].Text = "HelloWorld";

//Adding text with formatting to page headers
//Adding text with red color formatting to the left header
worksheet.PageSetup.LeftHeader = "&KFF0000 Left Header";
worksheet.PageSetup.CenterHeader = "&KFF0000 Center Header";
worksheet.PageSetup.RightHeader = "&KFF0000 Right Header";

//Adding text with formatting and image to page footers
//Adding text (sheet name) with red color formatting to the center header
worksheet.PageSetup.CenterHeader = "&KFF0000&A";

//Adding text (date and time) with red color formatting to the right header
worksheet.PageSetup.RightHeader = "&KFF0000&D &T";

//Adding bold text, font size 18, and blue color formatting to the left footer
worksheet.PageSetup.LeftFooter = "&B &18 &K0000FF Left Footer";

//Adding an image placeholder to the center footer
FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/image.jpg"), FileMode.Open);
worksheet.PageSetup.CenterFooter = "&G";
worksheet.PageSetup.CenterFooterImage = Image.FromStream(imageStream);
worksheet.PageSetup.RightFooter = "&P &K0000FF Right Footer";

//Adding the file name to the right footer with blue color formatting
worksheet.PageSetup.RightFooter = "&K0000FF&F";

//Saving the workbook as stream
FileStream stream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create);
Expand Down
Loading