Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Commented Unassigned: Image resizing when column resizes [15426]

$
0
0
Ok, so this is driving me crazy. I have lost days trying to solve this and I cant work it out!

I am using version 4.0.5

I have created a beautiful excel report, with images column A. I need to resize column A but this causes the images to stretch! I have created a test based on this with a few simple steps to re-create:

1. I load an Excel template
1. Which has an image in cell A1
1. I Resize column A
1. The image stretches - which I don't want it to do. I want it to stay the same.

I have tried every option for eEditAs and nothing stops the image from stretching. I have also set DoAdjustDrawings to false.

Here is my code - templateFileName will contain the full path to the template which I have attached.

```
var mem = new MemoryStream();

using (var excel = new ExcelPackage())
using (var template = File.OpenRead(templateFileName))
{
excel.Load(template);
excel.DoAdjustDrawings = false;
var sheet = excel.Workbook.Worksheets.First();

foreach (ExcelDrawing drawing in sheet.Drawings)
{
drawing.EditAs = eEditAs.Absolute; // have tried everything here
}

sheet.Column(1).Width = 200;

excel.SaveAs(mem);

mem.Flush();
mem.Position = 0;
}

return mem;
```
Comments: So after some more playing around with settings, it appears that the DoAdjustDrawings property is the culprit for some reason. If I leave this to true and have the EditAs set to eEditAs.Absolute the image stays the same size. As soon as I set to false the image stretches. This is really odd, I'm not sure why. The document says: "Automaticlly adjust drawing size when column width/row height are adjusted, depending on the drawings editBy property. Default True" So I would have thought setting to false would not automatically adjust the drawing size?

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>