Hi
In Aspose Cells for Java, we are using the following code snippet for inserting the footer text
if(sheet != null) {
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setFooterMargin(0);
// pageSetup.setFooter(2, watermarkText); // 2 represents the section where you want to add the watermark (Center section in the footer)
// String wtxt = “&KFF0000”+watermarkText;
//01/01/2024 to set font size to 8
// String wtxt = “&KFF0000&8”+footerText+“&D”+footerText1;
//trying to include time also on 05/16/2024
String wtxt = “&KFF0000&8”+footerText+“&D”+ " " + “&T” + footerText1;
// pageSetup.setFooter(2,wtxt );
//to set the footer in the center
pageSetup.setFooter(1,wtxt );
We are using the licensed version of Aspose. The footer text is showing in grey colour.
As you can see in the snippet,we are already using the hexadecimal color code for Red FF0000 in the code. The footer text is still not showing in red colour,can you help?
Thanks
@Rama_Menon
Cause
The issue of footer text appearing in grey color, despite specifying a red color using the hexadecimal code, is likely due to the way the footer formatting is being applied in Aspose.Cells. The footer text color can default to grey if the settings are not correctly interpreted or if there are conflicts with other formatting options.
Solution
To ensure that the footer text displays in the desired color, you can implement the following adjustments:
- Check the Color Code: Confirm that the color code is correctly formatted. The format
&KFF0000
should work for red, but it’s essential to double-check.
- Use Font Size and Style: Specify the font size and style correctly in the footer string. You can combine the color, font size, and other formatting in a single string.
- Set Footer for All Sections: To ensure consistency, set the footer for all sections (left, center, right) using the same formatting.
Code
Here’s a modified version of your code snippet that incorporates these suggestions:
if(sheet != null) {
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setFooterMargin(0);
// Combine color, font size, and text
String footerText = "&KFF0000&8" + footerText + " &D " + "&T " + footerText1;
// Set footer for all sections
pageSetup.setFooter(0, footerText); // Left section
pageSetup.setFooter(1, footerText); // Center section
pageSetup.setFooter(2, footerText); // Right section
}
Next Steps
- Test the modified code to verify that the footer text now appears in red.
- If the issue persists, check for any global settings or printer settings that might affect the footer appearance.
- Review the documentation on header and footer formatting in Aspose.Cells for additional options that may be relevant.
Please let me know if this resolves the issue!
@Rama_Menon
We can obtain the correct results by testing on the latest version v25.7 using the following sample code. Please refer to the attachment. out_java.zip (6.7 KB)
Workbook wb = new Workbook();
Worksheet sheet = wb.getWorksheets().get(0);
if(sheet != null) {
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setFooterMargin(0);
// Combine color, font size, and text
String footerText = "&KFF0000&8" + "testdata1" + " &D " + "&T " + "testdata2";
// Set footer for all sections
// Left section
pageSetup.setFooter(0, footerText);
// Center section
pageSetup.setFooter(1, footerText);
// Right section
pageSetup.setFooter(2, footerText);
}
wb.save(filePath + "out_java.xlsx");
We recommend you to kindly try using our latest version: Aspose.Cells for Java v25.7.
If you still find the issue, kindly do share your complete sample (runnable) code and result file to reproduce the issue on our end, we will check it soon.