We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting font color for header and footer text in .NET

Hi,

This is the command syntax that will be used to set header and footer with different fonts and colors.

&”,”&KYOURTEXT

So in C#,

It will be like this

String script=”&\”Arial, Bold\”&KFF00FFThis is your Text”

In the code below, 0 means left side section of the header, 1 means center side of header and 2 means right side of header.

I have set the left section in red color, center section in green color and right section in blue color.

Each section has been set in different fonts. Same thing was repeated with footer text.

Please see the screenshot to see how the output looks.

C#


Workbook excel = new Workbook();


Aspose.Cells.PageSetup pageSetup = excel.Worksheets[0].PageSetup;


//Script


String script0 = “&“Calibri, Bold”&KFF0000Red - Left Calibri”;

String script1 = “&“Verdana, Bold”&K00FF00Green - Center Verdana”;

String script2 = “&“Courier New, Bold”&K0000FFBlue - Right Courier”;


pageSetup.SetHeader(0, script0);

pageSetup.SetHeader(1, script1);

pageSetup.SetHeader(2, script2);


pageSetup.SetFooter(0, script0);

pageSetup.SetFooter(1, script1);

pageSetup.SetFooter(2, script2);


excel.Save(@“f:\downloads\output.xlsx”);

Hi, How do I write the script to give the footer a background color:


Regards

Hi,


I don’t think it is even possible in Excel application to specify a color for the footer/header background. If you have a different opinion, kindly create a sample spreadsheet in Excel application with header/footer set with background/fill color and attach it here along with steps to accomplish the task. We will check it soon.