2

I am using EPPlus Version 4.1.0 I know this issue seems extremely weird but I have already wasted 2 days on this and any input is very very welcome!

I run the following code:

using (var package = new ExcelPackage())
{
    ExcelWorksheet ws = package.Workbook.Worksheets.Add("Sheet1");
    ...
    for (int i = ws.Dimension.Start.Column; i <= ws.Dimension.End.Column; i++)
    {
        ws.Column(i).AutoFit(0, 100);
        ws.Column(i).Style.WrapText = ws.Column(i).Width > 60;
    }
...

I run this code on several machines and the AutFit() function always returns the same value for the column width.

But on one machine the (unfortunately my new laptop) the width is completely off (i.e. 33 instead of expected 11).

Any clues how my machine setup can possibly effect this?

w33z33
  • 378
  • 2
  • 17
  • 3
    Is you new laptop running a hi-rez screen? If so, you probably have your DPI set much higher then 100% which may explain the difference. – Ernie S Jan 05 '17 at 01:24
  • yeah that was actually it. do you have any idea if this is effecting the final document for the client? – w33z33 Jan 05 '17 at 13:43
  • 2
    I havent run into that one before. It may. If you look at the code where Epplus autofits in ExcelRangeBase.cs you will see it does some calculations based on the size of the text the cell contains in a System.Drawings.Graphics object. Since this is on the server it will not be able to account for the users scaling. Sorry I cant help more... – Ernie S Jan 05 '17 at 21:12

1 Answers1

1

I hope somebody else can benefit from this, but as stated in the comments, it was actually the DPI settings of my new machine that caused this.

I have yet to find out if this actually affects the reports itself.

w33z33
  • 378
  • 2
  • 17