Header Font and Carriage Return

I have having trouble putting a carraige return into a string in the pageSetup Header. I tried “\n” with no luck, it just prints "\n."


Also the example for changing the font does not work for me.

pageSetup.SetHeader(1, “TEST TEXT &“Courier New”&14 123”)

Is giving me an error in my .NET code saying character constant must contain exactly one character.

BTW I’m evaluating this product for a client and am building a test page for them.

There are some error in VB sample code of programmer’s guide. I will fix it.

Please change you code to:

pagesetup.SetHeader(1, “TEST” + vbCrLf + “TEXT &”“Courier New”"&14 123")

Sorry for any inconvenience.

Thanks for the reply, Font size doesn’t seem to be working here’s my code

pageSetup.SetHeader(2, vbCrLf + “Test Text &”“Monospac821 BT”"&8")

Please put the font setting before your text. Try this:

pagesetup.SetHeader(2, vbCrLf + “&”“Monospac821 BT”"&8 Test Text")

@jchanyaem02,
Aspose.Excel is discontinued and no more development is done for it. A new product Aspose.Cells is introduced which is far better in performance and range of features. You can set header and font using this new product as well as shown in the following sample code:

// Instantiating a Workbook object
Workbook excel = new Workbook();

// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = excel.Worksheets[0].PageSetup;

// Setting worksheet name at the left section of the header
pageSetup.SetHeader(0, "&A");

// Setting current date and current time at the centeral section of the header
// and changing the font of the header
pageSetup.SetHeader(1, "&\"Times New Roman,Bold\"&D-&T");

// Setting current file name at the right section of the header and changing the
// font of the header
pageSetup.SetHeader(2, "&\"Times New Roman,Bold\"&12&F");

// Setting a string at the left section of the footer and changing the font
// of a part of this string ("123")
pageSetup.SetFooter(0, "Hello World! &\"Courier New\"&14 123");

// Setting the current page number at the central section of the footer
pageSetup.SetFooter(1, "&P");

// Setting page count at the right section of footer
pageSetup.SetFooter(2, "&N");

// Save the Workbook.
excel.Save("SetHeadersAndFooters_out.xls");

For ore information about setting header and footer visit the following article:
Setting Headers and Footers

Here is the link to the free trial version of the product:
Aspose.Cells for .NET (Latest Version)

Download a runnable solution here which can be used to test the product features readily.