Can I use the Excel JavaScript API to a header image in the page layout?

Ian 0 Reputation points
2025-01-21T20:04:26.7833333+00:00

I am trying to add a watermark using the header in the page layout of an Excel sheet.

In API reference for Excel.HeaderFooter class there are properties for each header and footer section that can be set with the API. The API reference for the header properties has a link to format codes that can be set. One of those format codes is &G which has the description "Inserts and image.", but I have not had any luck using it.

If I manually add an image to the worksheet header it appears as &[Picture] in the worksheet, and the property for the HeaderFooter class is &G. If I set the property to an empty string then the image disappears, but if I try to add &G back the image does not reappear.

I am guessing that the image needs to be passed in somehow, and I have tried doing that several way with no success. Does anyone know if there is way to set the header image using the javascript api?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,035 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.