简体   繁体   English

C#Excel Interop:如何以像素为单位设置单元格的高度和宽度?

[英]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. 我将不会有意在此问题中张贴任何代码,因为不需要回答此问题,由于某些原因,我需要通过像素值而不是接受标准的activeWorksheet.Rows.RowHeight来设置工作表中单元格的高度和宽度标准值。 How can I successfully set Height and Width of a cell via pixels? 如何通过像素成功设置单元格的高度和宽度? Thanks. 谢谢。

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 . 获得C#中的DPI,请参见this

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM