This project has moved and is read-only. For the latest updates, please go here.

Windows form is resized when setting size/location of image/chart/row in excel worksheet

Sep 1, 2016 at 9:02 AM
I'm using epplus to export excel files from a windows forms application. It all works fine except if I run the application on a laptop with non standard font size, the form is resized when I modify certain things in the generated excel worksheets, e.g. position an image, resize a chart or set height of a row. What can be the reason, and how to prevent this from happening?
Sep 1, 2016 at 10:06 AM
Found the problem: it seems some libraries are loaded in these situations that change the dpi awareness of the process (see http://www.telerik.com/blogs/winforms-scaling-at-large-dpi-settings-is-it-even-possible-). The solution is to change dpi awareness (for me it was sufficient to call it in the form's constructor):

[DllImport("shcore.dll")]
static extern int SetProcessDpiAwareness(int value);

SetProcessDpiAwareness(0)