Header and footer--need author name

Hi Ahmed,

I am trying to create a Footer where I need to print like: prepared by ....... (would be the author name).

In the API for creating headers and footers, there are Script Commands which serve different purposes but not for author name. Could you please let me know on how can I make sure that my author name appears in the header/footer like: prepared by: author name.

regards,
perindev


This message was posted using Email2Forum by ShL77.

Hi Perindev,

May the following sample code help you for your reqirement, kindly consult it.

//Instantiate an Workbook object by calling its empty constructor
Workbook workbook = new Workbook();

//Open and Workbook file by calling the Open method of the Workbook object
workbook.open("e:\\files\\testdocproperty.xls");


//Retrieve a list of all the document properties of the Workbook file
BuiltInDocumentProperties docProperties = workbook.getWorksheets().getBuiltInDocumentProperties();


//Accessng a custom document property by using the property name
DocumentProperty cProperty2 = docProperties.get("Author");

//Getting values.

String author = (String)cProperty2.getValue();


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

//Setting a string at the left footer and changing the font of the footer
pageSetup.setLeftFooter("Prepared By: " + author);

//Save the file.
workbook.save("e:\\files\\outfooteradded.xls");

Thank you.