Skip to content

Commit

Permalink
Worksheet Features
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurmitha4004 committed Oct 22, 2024
1 parent 6f6c0c3 commit dde8676
Showing 1 changed file with 13 additions and 5 deletions.
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

0 comments on commit dde8676

Please sign in to comment.