How to reduce font size in excel footer using Aspose Cells for Java API

Hi
Is there any way to reduce font size in excel footer using Aspose Cells for Java API.

Right now i am using the following code to set the footer.

private boolean watermarkTextExcelFile (File excelFile, String watermarkText, String fileSuffix, String outputDirectory) throws Exception {

	boolean watermarkedFile = false;

	String fileName = "";
	try {

		fileName = excelFile.getName();
		String filePath = excelFile.getPath();
		String fileExtension = ".xlsx";
		if (!fileName.endsWith(".xlsx")) {
			fileExtension = ".xls";
		}

		//to apply license
		com.aspose.cells.License license = new com.aspose.cells.License();
		license.setLicense("Aspose.Total.Java.lic");
		String fileNameWithOutExt = FilenameUtils.removeExtension(fileName);

		// Load the Excel file
		Workbook workbook = new Workbook(filePath);

		//WorksheetCollection worksheets = workbook.getWorksheets();
		int worksheetCount = 100;
		for (int i = 0; i < worksheetCount; i++) {

			// Get the first default sheet
			Worksheet sheet = null;

			try {
				sheet = workbook.getWorksheets().get(i);
			}
			catch (Exception ex) {
				//	logger.error("watermarkTextExcelFile load sheet ex:" + ex.getMessage());
				errlog.error("watermarkTextExcelFile load sheet ex:" + ex.getMessage() + ": " + fileName);

			}

			if(sheet != null) {
				PageSetup pageSetup = sheet.getPageSetup();
				//pageSetup.setFooter(2, watermarkText); // 2 represents the section where you want to add the watermark (Center section in the footer)
				pageSetup.setFooterMargin(0);
                                    String wtxt = "&KFF0000"+watermarkText;
				pageSetup.setFooter(1,wtxt );


			}
			else {
				// no sheet
				break;
			}
		}

		// Save the watermarked Excel file
		String watermarkedFilePath = outputDirectory + fileSeparator + fileNameWithOutExt + fileSuffix + fileExtension;
		workbook.save(watermarkedFilePath);

		//	logger.debug("watermarkedFilePath: " + watermarkedFilePath);
		infolog.info("watermarkedFilePath: " + watermarkedFilePath);

		watermarkedFile = true;
	}
	catch (Exception ex) {
		//	logger.error("watermarkTextWordFile ex:", ex);
		errlog.error("watermarkTextExcelFile ex:" + ex + ":" + fileName);

	}

	return watermarkedFile;
}

Thanks
Sabarish

@sabkan,

You may use relevant script commands provided by Aspose.Cells to set font with its style and/or its size accordingly for headers/footers for your needs.
1). &"<FontName>" —> a font name. For example: &“Arial”.
2). &"<FontName>, <FontStyle>" —> a font name with a style. For example: &“Arial,Bold”.
3). &<FontSize> —> represents font size. For example: “&14abc”. But, if this command is followed by a plain number to be printed in the header, this should be separated with a space character from the font size. For example: “&14 123”.
e.g.
Sample code:

// Instantiating and opening the Excel workbook
Workbook workbook = new Workbook("Book1.xlsx");

// Obtaining the reference of the PageSetup of the first worksheet
PageSetup pageSetup = workbook.getWorksheets().get(0).getPageSetup();

// 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 while changing the font (name, style and its size) of the header
pageSetup.setHeader(2, "&\"Times New Roman,Bold\"&12&F");

// Setting a string at the left footer and changing the font (set name to "Courier New" and font size to "10") of the footer
pageSetup.setFooter(0, "Hello World! &\"Courier New\"&10 123");

workbook.save("SetHeadersAndFooters_out.xlsx");

For complete reference with example codes, please see the document:
https://docs.aspose.com/cells/java/page-setup-features/#setting-headers-and-footers

Hope, this helps a bit.

@amjad.sahi

Thanks for the detailed reply.

@sabkan,

You are welcome.
Should you have further queries or comments, please feel free to contact us back.