Footer and Header

Hi,

I’m looking for a method to read footer and header. I’ve only found the method to set them.


Andreas

Please check http://www.aspose.com/Products/Aspose.Excel/Api/Aspose.Excel.PageSetupMembers.html
for PageSetup GetHeader and GetFooter methods.

@uniserv,
Aspose.Excel is discontinued now and no more available. It is replaced by Aspose.Cells that contains all the advanced features of the different versions of MS Excel. You can set and get the header and footer also using this new product as demonstrated in the following sample code.

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

//Adding a new worksheet to the Workbook object
WorksheetCollection worksheets = workbook.Worksheets;

Worksheet worksheet = worksheets.Add("My Worksheet");
//Obtaining the reference of the PageSetup of the worksheet

PageSetup pageSetup = worksheet.PageSetup;
//Setting worksheet name at the left  header

pageSetup.SetHeader(0, "&A");
//Setting current date and current time at the central header

//and changing the font of the header
pageSetup.SetHeader(1, "&\"Times New Roman,Bold\"&D-&T");

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

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

//Setting picture at the central footer
pageSetup.SetFooter(1, "&G");

workbook.Save("headerfooter.xlsx");
String data1 = pageSetup.GetHeader(0);
String data2 = pageSetup.GetHeader(1);
String data3 = pageSetup.GetHeader(2);

String data4 = pageSetup.GetFooter(0);
String data5 = pageSetup.GetFooter(1);
String data6 = pageSetup.GetFooter(2);

Console.WriteLine(data1);
Console.WriteLine(data2);
Console.WriteLine(data3);
Console.WriteLine(data4);
Console.WriteLine(data5);

For more details to set and get the headers and footers, refer to the following article:
Setting headers and footers

A free trial version can be downloaded here:
Aspose.Cells for .NET(Latest version)

You can download a ready to run solution here that can be used to test different features of this product without any coding.