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

Free Support Forum - aspose.com

Image before text in header

Hi,

Is there any way to insert image into header before the text? If I call setCenterHeader() and then addPicture() picture is after the text. If I call addPicture() and then setCenterHeader() only text appears.

Thanks


Best regards

Hi,

I think you may refer to the following sample code, I have tried and it works. I have inserted an image/log and datetime (after the image) in the same center header section.

Sample code:

//Creating a Workbook object
Workbook workbook = new Workbook();
//Creating a string variable to store the url of the logo/picture
String logo_url = “f:\test\school.jpg”;

//Creating the instance of the FileInputStream object to open the logo/picture in the stream
FileInputStream inFile = new FileInputStream(logo_url);
//Creating a PageSetup object to get the page settings of the first worksheet of the workbook
PageSetup pageSetup = workbook.getWorksheets().getSheet(0).getPageSetup();

//Setting the logo/picture and datetime(text) in the central section of the page header
pageSetup.setCenterHeader("&G\n&“Times New Roman,Bold”&D-&T");
pageSetup.addPicture(true,1,inFile);

//Saving the workbook
workbook.save(“e:\files\outputfile.xls”);


Thank you.

Hi,

This is what works to me. Whats not working is:

pageSetup.addPicture(true, 1, inputStream);

and then
pageSetup.setCenterHeader("Center header");


First picture, then text..

Thanks

Hi,

I think you may try:
pageSetup.addPicture(true,1,inFile);
pageSetup.setCenterHeader("&G\nCenter header");

I have tried the above code and it works fine.

Thank you.

Great… Thank you