Skip to content

jx:image

jx:image inserts an image from byte data into the specified cell area. Use it for employee photos, company logos, product images, chart screenshots, or any visual content.

jx:image(src="employee.Photo" imageType="PNG" lastCell="C5")
AttributeDescriptionDefaultRequired
srcExpression for image bytes ([]byte)Yes
imageTypeFormat: PNG, JPEG, GIF, etc.Yes
lastCellBottom-right cell defining the image areaYes
scaleXHorizontal scale factor1.0No
scaleYVertical scale factor1.0No
logoBytes, _ := os.ReadFile("logo.png")
data := map[string]any{
"company": map[string]any{
"Name": "Acme Corp",
"Logo": logoBytes,
},
}

Template cell A1 comment:

jx:image(src="company.Logo" imageType="PNG" lastCell="C3")

The image fills the A1:C3 area. The cell dimensions control the image size.

Adjust the image size relative to the cell area:

jx:image(src="logo" imageType="PNG" scaleX="0.5" scaleY="0.5" lastCell="B2")

Combine with jx:each for a different image per row — employee photos, product thumbnails, etc.:

Cell A1 comment:
jx:area(lastCell="D3")
jx:each(items="employees" var="e" lastCell="D3")
Cell A1 also has:
jx:image(src="e.Photo" imageType="JPEG" lastCell="A3")

Each employee gets their photo in column A, with name/details in columns B-D.

Download the runnable example: template t10.xlsx | output 10_image.xlsx | code snippet

Need to merge cells for section headers?

jx:mergeCells →