8000 Image location don't respect Column width · Issue #650 · exceljs/exceljs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Image location don't respect Column width #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yuvpf opened this issue Sep 17, 2018 · 11 comments
Open

Image location don't respect Column width #650

yuvpf opened this issue Sep 17, 2018 · 11 comments
Labels

Comments

@yuvpf
Copy link
yuvpf commented Sep 17, 2018

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

@GendelfLugansk
Copy link

@yuvpf did you find any workaround?

@Siemienik
Copy link
Member

@yuvpf @GendelfLugansk
Hello guys, i fix it in pull request #702,
if You need it quicly, i have build branch in my repo:
https://github.com/p3rio/exceljs/tree/build

npm:

    "dependencies": {
        "exceljs": "github:p3rio/exceljs#build"
    }

@ShraddhaJ11
Copy link

Hi @Siemienik Still facing image alignment issue with custom column width.

@Siemienik
Copy link
Member

hmm.. it works for me really well, which version have you?

@ShraddhaJ11
Copy link

hmm.. it works for me really well, which version have you?

I am using 4.0.1. How you are calculating colOff and rowOff?

@Siemienik
Copy link
Member

it's enough to specify col and row values. collOff and rowOff will be calculated during saving

@ShraddhaJ11
Copy link

Thanks for the response @Siemienik .
I am facing a issue when I am trying to align image to the right of a particular cell with custom column width i.e. if we change the column width to some other width and try to right align image in a cell of that column using col and row coordinate then image is not displaying in the right.

image

In the above image I want cross image same as tick image in size and cross image should right align within the cell. Did you have any solution for this ?

@Siemienik
Copy link
Member

after that you changed column width, are col and row properties has the same value as before?

@ShraddhaJ11
Copy link

First I am reading a excel file and then I am only adding the image on a particular cell. If width of the column for that cell is default column width then image alignment is working fine using col and row but If the excel file that I am reading, have custom column width then adding image to a cell that has custom width , in that right image alignment is not working.

@Siemienik Siemienik added the bug label Jun 20, 2020
@yulduck
Copy link
yulduck commented Sep 27, 2021

Is there any workaround for this bug at the moment?

@rsl081
Copy link
rsl081 commented Jun 11, 2023

Good day guys,

I'm also facing the same problem. The version that I already trying is the latest 4.3.0 and this one 4.2.1.
When adding an image using coordinate (70% column), the image doesn't respect my custom width.

is there any workaround for this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants
0