FabioEnne
FabioEnne

Reputation: 742

C# Excel Interop: How to set cells height and width in pixels?

I will not intentionally post any codes in this question as it is not needed to answer this question, for some reasons I need to set Height and Width of the cells in my worksheet via pixels value and not the standard activeWorksheet.Rows.RowHeight which accept standard value. How can I successfully set Height and Width of a cell via pixels? Thanks.

Upvotes: 2

Views: 4840

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65554

The formula:

pixels = points * DPI / 72

can be reversed to:

points = pixels / DPI * 72

This way you can set Row Height using pixels.

To get the DPI in C# see this.

Upvotes: 3

Related Questions