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