[英]Using ClosedXML how to adjust image size according row height
I set a row height. 我设置行高。 After that I place picture in first cell. 之后,我将图片放在第一个单元格中。 How can I adjust image size according row height? 如何根据行高调整图像尺寸?
worksheet.Row(1).Height = 265;
var image = worksheet.AddPicture(imagePath).MoveTo(worksheet.Cell("A1"));
The worksheet.Row(1).Height = 265
statement just changes the height of the row . worksheet.Row(1).Height = 265
语句仅更改row的高度。 If you want to change the height of the image , use something like: 如果要更改图像的高度,请使用以下方法:
var image = worksheet.AddPicture(imagePath).MoveTo(worksheet.Cell("A1")).WithSize(265, 265);
To retain proportions of the image you can use Scale method 要保留图像的比例,可以使用缩放方法
ws.Row(1).Height = 300;
var pic = ws.AddPicture(imageFile, "Logo").MoveTo(ws.Cell(1, 1));
pic.Scale( ws.Row(1).Height / (pic.OriginalHeight * 0.75d));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.