From dde86769e5e242bfe08b944198b395c6a7c7401c Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Tue, 22 Oct 2024 18:41:19 +0530 Subject: [PATCH] Worksheet Features --- .../Header and Footer/Program.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Worksheet Features/Header and Footer/.NET/Header and Footer/Header and Footer/Program.cs b/Worksheet Features/Header and Footer/.NET/Header and Footer/Header and Footer/Program.cs index 0b37d16a..71139920 100644 --- a/Worksheet Features/Header and Footer/.NET/Header and Footer/Header and Footer/Program.cs +++ b/Worksheet Features/Header and Footer/.NET/Header and Footer/Header and Footer/Program.cs @@ -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);