Skip to content

AddPicture's OffsetY Method will cause the image to be displayed incorrectly #1560

Closed
@jacobLiou1225

Description

@jacobLiou1225

Description
(想知道為何OffsetY一旦>=20就會使圖片跑版,謝謝)
I want to place two pictures in a cell using the AddPicture Method, but when my OffsetY is greater than 20, the position of the pictures becomes incorrect.

Describe the results you received:

This is the result when OffsetY is 19.
image

This is the result when OffsetY is 20.
image

The image that was supposed to be in cell A1 has shifted to A2.
I have also tried using AutoFit: true but it didn't solve my problem.

Here's my code:

package main

import (
	_ "image/jpeg"
	_ "image/png"

	"github.com/xuri/excelize/v2"
)

func main() {
	f, _ := excelize.OpenFile("cat.xlsx")
	f.AddPicture("cat", "A1", "cat.png",
		&excelize.GraphicOptions{
			AutoFit:     true,
			ScaleX:      1,
			ScaleY:      1,
			OffsetX:     10,
			OffsetY:     20,
			Positioning: "absolute",
		},
	)
	f.SaveAs("output.xlsx")
}

here's the repository
https://github.com/jacobLiou1225/API-AddPicture-Question.git

Excelize version or commit ID: 2.7.1
golang version 1.19
Environment details : windows 10 21H2

Any help on this issue would be greatly appreciated. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions