Posted 13 September 2022, 4:09 pm EST
I’m working on a sheet where i should add the logo of a company if there is one.
i face a problem as all the logo don’t have the same size, so the image is twisted.
Here is my method to add the picture :
public void AddLogo(Guid? brokerEnterpriseId, IWorksheet workingSheet)
{
var ets = _enterpriseQueryProcessor.Query()
.Where(x => x.Id == brokerEnterpriseId)
.FirstOrDefault();
if (ets.LogoUrl == null)
{
workingSheet.Range["A2"].Value = ets.Name;
return;
}
using (WebClient webClient = new WebClient())
{
byte[] data = webClient.DownloadData(ets.LogoUrl);
var str = new MemoryStream(data);
workingSheet.Shapes.AddPicture(str, ImageType.PNG, 10,3,50,50);
}
}
Is there any solution to keep the ratio when using “AddPicture” ? Or any solution ?
Thanks in advance.