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

Free Support Forum - aspose.com

Excel Java Footer Problem

Cells 8.0.0
Microsoft Excell 2010

When operating on a single page excel file Aspose does not correctly add a footer.

Create and empty excel file. (xlsx).

Open the file, go to page layout, add a left footer. "First Page Footer"
Make sure different on first page, scale with doc, align with page is selected.
Save the document.
Expand the zip, look at the sheet1.xml file and check out the XML.
You should see

First Page Footer

Now save that file for future ref.

Open the file again. Go to page layout. Put some text in cells B:30 and K:30 (So we have 2 pages).
Make sure different on first page, scale with doc, align with page is selected.
On the first footer make it the same as the above steps.
On the second footer make it "Second Page Footer"

Save the file, extract the sheet1.xml and check out the xml.

You now get.

Second Page Footer
First Page Footer

Aspose in both cases uses firstFooter.


Could you provide us your sample code (runnable) that you are using via Aspose.Cells APIs. Also provide the output Excel file by Aspose.Cells with your expected file that you may manually create in MS Excel, we will check your issue soon.

Also, please download and try our latest version: Aspose.Cells for Java v8.0.1.3

Thank you.

Try this. If this is the incorrect way to set the headers on the first page let me know.

public class TestClass {

public static final int LEFT = 0;
public static final int CENTER = 1;
public static final int RIGHT = 2;

public static void main(String[] args) throws Exception{

Workbook workBook = new WorkBook();
WorksheetCollection workSheets = workBook.getWorksheets();

for ( int x = 0 ; x < workSheets.getCount(); x++ ) {
Worksheet wks = workSheets.get(x);
PageSetup pageSetup = wks.getPageSetup();

pageSetup.setFirstPageHeader(LEFT, “First Page Left Header”);
pageSetup.setFirstPageHeader(CENTER, “First Page Center Header”);
pageSetup.setFirstPageHeader(RIGHT, “First Page RightHeader”);

pageSetup.setFirstPageFooter(LEFT, “First Page Left Footer”);
pageSetup.setFirstPageFooter(CENTER, “First Page Center Footer”);
pageSetup.setFirstPageFooter(RIGHT, “First Page Right Footer”);




I have tested your scenario/ case and I think you are right, Aspose.Cells uses “firstFooter” tag where as MS Excel uses “oddFooter”. We will further investigate it but I think it works fine for all the scenario and also when opening the file into MS Excel to see the PageSetup settings etc. Do you find any issue with this kind of configuration in the sheeet1.xml file?

Thank you.

With a single page excel file the header and footers do not print.

Is there any what to figure out how many pages would be printed? If I could do that, then I could modify the code for the type of headers I need. We usually need the first headers and footers to be different than the rest.


Well, to get the total number of pages a worksheet can have via SheetRender APIs, you may try:
Sample code:

ImageOrPrintOptions printoption = new ImageOrPrintOptions();
printoption.PrintingPage = PrintingPageType.Default;
//Get the first worksheet
Worksheet = workbook.Worksheeets[0];

SheetRender sr = new SheetRender(worksheet, printoption);
int pageCount = sr.PageCount;

Thank you.