Skip to content

Image location don't respect Column width #650

Open
@yuvpf

Description

@yuvpf

I set custom column width while defining sheet columns. When adding an image using coordinate (50% column to use), the image don't respect my custom width.

Additional explanation: #650 (comment)

Code :

      sheet.columns = [
          { header: 'Id', key: 'id', width: 10 },
          { header: 'Name', key: 'name', width: 32 },
      ];

      var imageId2 = workbook.addImage({
        base64: myBase64Image,
        extension: 'png',
      });

      sheet.getColumn(4).width = 38;
      // sheet.addImage(imageId2, 'B2:D6');
      sheet.addImage(imageId2, {
                          tl: { col: 1, row: 1 },
                          br: { col: 1.5, row: 4 }
                        });

      sheet.addImage(imageId2, {
                          tl: { col: 3, row: 1 },
                          br: { col: 3.5, row: 4 }
                        });


      workbook.xlsx.writeBuffer({
                  base64: true
              })
      .then(function(xls64) {
          // done
          var data = new Blob([xls64], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
          saveAs(data, "output.xlsx");
      });

Actual result :

image

Expected result:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions