简体   繁体   English

获取以像素为单位的Excel列的宽度,而不是默认的度量单位

[英]Get width of an Excel column in pixels instead of the default unit of measurement

It appears from some experiments I performed and from reading this page that the default units of measurement of the column width and row height in Excel are not pixels or even the standard metric such as centimeters but they are the number of characters that will fit in the space. 从我执行的一些实验以及阅读此页面后看来,Excel中列宽和行高的默认度量单位不是像素,甚至不是标准度量单位(例如厘米),而是单位为英寸的字符数。空间。

I am using Aspose Cells for Java. 我正在使用Aspose Cells for Java。 How do I get the width of a column in pixels? 如何获得以像素为单位的列的宽度?

Well, you may try to use Cells.getColumnWidthPixel() to get a column's width in the units of pixel, see the sample code for your reference. 好吧,您可以尝试使用Cells.getColumnWidthPixel()获得以像素为单位的列宽,请参阅示例代码以供参考。 eg Sample code: 例如示例代码:

Workbook wb = new Workbook("Book1.xlsx");
Worksheet ws = wb.getWorksheets().get(0);
Cells cells = ws.getCells();

//Get the second column's width in pixels, i.e, B.
int colwidth = cells.getColumnWidthPixel(1);

System.out.println(colwidth);

Similarly you may try to use Cells.getRowHeightPixel() to get the row height in pixel. 同样,您可以尝试使用Cells.getRowHeightPixel()获取以像素为单位的行高。

I am working as Support developer/ Evangelist at Aspose. 我在Aspose担任技术支持/开发人员。

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

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