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

2.6k views Asked by At

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?

1

There are 1 answers

0
Amjad Sahi On BEST ANSWER

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. e.g 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.