qax-os / excelize

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
17.62k stars 1.68k forks source link

Added picture is taking the whole sheet/view #1902

Closed kirqe closed 1 month ago

kirqe commented 1 month ago

Description

I generate an qr with https://github.com/yeqown/go-qrcode and place it into a cell. I have tried scaling options, changing format etc I'm getting the following result in the preview app. The whole screen is taken by the qr.

When I create a normal screenshot and place it into a cell there're no issues

Is this the bug of this package or go-qrcode?

Steps to reproduce the issue:

  1. Generate a qr

    
    f := fmt.Sprintf("%s/%s.png", directory, filename)
    
    w, _ := standard.New(f, standard.WithBuiltinImageEncoder(standard.PNG_FORMAT))
    
    if err = qrc.Save(w); err != nil {
        log.Fatal("error saving qr: %v", err)
    }
  2. Try to add it to some sheet with the default examples

        enable, disable := true, false
        if err := f.AddPicture("Sheet1", "A2", "sample3.png",
            &excelize.GraphicOptions{
                PrintObject:     &enable,
                LockAspectRatio: false,
                OffsetX:         15,
                OffsetY:         10,
                Locked:          &disable,
            }); err != nil {
            fmt.Println(err)
            return
        }

Describe the results you received:

I add only 1 picture!

image

-

image

Output of go version:

go version go1.22.3 darwin/arm64

Excelize version or commit ID:

    github.com/xuri/excelize/v2 v2.8.1
    github.com/yeqown/go-qrcode/v2 v2.2.4
    github.com/yeqown/go-qrcode/writer/standard v1.2.3
xuri commented 1 month ago

Thanks for your issue. Could you show us a complete, standalone example program or reproducible demo? If you open an existing workbook, please provide the file attachment without confidential info.

kirqe commented 1 month ago

@xuri I figured that the qr spread to the right because I updated widths after placing the image The problem is still there for vertical axis https://github.com/kirqe/issue-demo

Sorry if the way I map rows and add styles is incorrect :D

--

Looks like images need to be added after the loop Same for the styles and height I feel embarrassed :D