natergj / excel4node

Node module to allow for easy Excel file creation
MIT License
1.38k stars 215 forks source link

Set width and height in pixels and center image in cell #339

Open tiagocostaHB opened 3 years ago

tiagocostaHB commented 3 years ago

Hi,

I've been trying to set the row height and the column width to the exact size in pixels of an image added to the cell, but I can't make it to fit, I've been trying with the examples given here (https://github.com/natergj/excel4node/issues/182#issuecomment-375118910), for example setting the column width with:

ws.column(ws.lastUsedCol).setWidth( Math.trunc(((imageSize.width - 11) / 7) * 100 + 0.5) / 100 );

where imageSize.width is the pixels width but still it doesn't fit perfectly the image width, how can I implement this?

Also, how can I center an image in a cell by using the position colOff and rowOff?

Thanks