![](/img/trans.png)
[英]How to get the default column width of an Excel sheet with Apache-POI?
[英]Get width of an Excel column in pixels instead of the default unit of measurement
从我执行的一些实验以及阅读此页面后看来,Excel中列宽和行高的默认度量单位不是像素,甚至不是标准度量单位(例如厘米),而是单位为英寸的字符数。空间。
我正在使用Aspose Cells for Java。 如何获得以像素为单位的列的宽度?
好吧,您可以尝试使用Cells.getColumnWidthPixel()获得以像素为单位的列宽,请参阅示例代码以供参考。 例如示例代码:
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);
同样,您可以尝试使用Cells.getRowHeightPixel()获取以像素为单位的行高。
我在Aspose担任技术支持/开发人员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.