How to insert image FIT inside a cell ?
See original GitHub issueThanks for the great package. I want to insert image inside a cell. Currently, I’m using fixed width and height, but have no idea how to make image size fit inside a cell. How can I do that with exceljs
? Thanks in advance !
I want to
const tmpWorkBook = new ExcelJS.Workbook();
tmpWorkBook.xlsx.readFile(filePath)
.then(function() {
const worksheet = tmpWorkBook.getWorksheet("Sheet1");
var imageID = tmpWorkBook.addImage({
filename: imagePath,
extension: 'png',
});
console.log("imageID", imageID);
const relCol = cell.columnNumber() - 1;
const relNum = cell.rowNumber() - 1;
worksheet.addImage(imageID, {
tl: { col: relCol, row: relNum },
ext: { width: 100, height: 50 } // currently I'm using fixed width and height.
});
tmpWorkBook.xlsx.writeFile(outputPath);
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to insert picture in Excel cell, comment, header and footer
In the Insert Picture dialog that opens, browse to the picture of interest, select it, and click Insert. This will place the picture...
Read more >How to Insert Picture Into a Cell in Excel (a Step-by-Step ...
Go to the Insert tab. · Click on the Pictures option (it's in the illustrations group). · In the 'Insert Picture' dialog box,...
Read more >Insert Pictures in Excel Automatically Size to Fit Cells
From Format Picture >> select Size & Properties >> then select Properties. Mark on the option Move and size with cells.
Read more >How can I fit a picture in a cell in Microsoft Excel? - Quora
Click on the Insert tab · Insert picture · Resize the cells according to the picture · Right-click on the picture · Format...
Read more >How to resize pictures to fit cells in Excel? - ExtendOffice
Resize a selected picture to fit a single cell with VB Macro ; Resize inserted pictures to fit cells with Kutools for Excel...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
See the example of add image to a cell.
Not sure if you still need this, but what I did was using the same
cellId
fits inside the cell. I think this works because the same cell is used for the top left (tl) and the bottom right (br).Example: