dotnetcore / NPOI

A .NET library for reading and writing Microsoft Office binary and OOXML file formats.
Apache License 2.0
1.92k stars 413 forks source link

AnchorType.MoveDontResize does not work correctly when we set custom row height #156

Open majidmadadi opened 4 years ago

majidmadadi commented 4 years ago

When I change row height the image height also grows. My code is as the following:

private void AddImageToWorkBook(Image img, int colIndex, int rowIndex, XSSFWorkbook workbook, ISheet sheet) { var ms = new MemoryStream(); img.Save(ms, ImageFormat.Png); byte[] data = ms.ToArray(); int pictureIndex = workbook.AddPicture(data, PictureType.PNG); ICreationHelper helper = workbook.GetCreationHelper(); IDrawing drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = helper.CreateClientAnchor(); anchor.AnchorType = AnchorType.MoveDontResize; anchor.Col1 = colIndex;//0 index based column anchor.Row1 = rowIndex;//0 index based row IPicture picture = drawing.CreatePicture(anchor, pictureIndex); picture.Resize(); }

When I change the row height before or after calling this function, then the generated image will grow too while I've set the AnchorType to MoveDontResize. Expected behavior: Image size should not grow with row height.