Reputation: 45
I can place the image into the excel but it takes up cells A1 to around 3/4 of D12. I tried searching up ways to resize the image but most of the links provided were deleted from previous users. My goal is to put the image into the cell A1 and resize that cell to fit the picture but I also want to make the picture smaller.
Any ideas or links?
byte[] data = File.ReadAllBytes("logo.png");
int picInd = workbook.AddPicture(data, NPOI.SS.UserModel.PictureType.PNG);
ICreationHelper helper = workbook.GetCreationHelper();
IDrawing drawing = sheet.CreateDrawingPatriarch();
IClientAnchor anchor = helper.CreateClientAnchor();
anchor.Col1 = 0;//0 index based column
anchor.Row1 = 0;//0 index based row
IPicture picture = drawing.CreatePicture(anchor, picInd);
picture.Resize();
Upvotes: 1
Views: 967
Reputation: 45
Apparently you just set the size of the photo outside of the code and it will affect it when it transfers to excel. A lot of scale down scale up and retrying till it looks nice.
Upvotes: -1