简体   繁体   中英

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.

I am using 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. 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.

I am working as Support developer/ Evangelist at Aspose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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