We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cells.getColumnWidth() calculation

What would be the recommended way to convert the width of a cell (Cells.getColumnWidth()) into points/pixels (similar to what Cells.getRowHeight() returns). It looks like getColumnWidth() returns the width in characters, so is there a way to then multiply this by whatever the default font size is to get a width that is in the same units as the row’s height?

Thanks for any help you can provide.

-Chad

Hi,

Thanks for considering Aspose.

Well, normally we follow MS Excel standards, so Cells.getColumnWidth() method returns the column width in characters unit (same as with MS Excel). And, we do provide Cells.getColumnWidthPixel() method to get a column width in pixel for your need. Which version of Aspose.Cells for Java you are using, please try our latest version 1.9.5 to use this method. I think this API is missing in Aspose.Cells for Java API Reference documentation: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/com/aspose/cells/cells.html , we will include it soon.

I think you may try to calculate characters to points yourself knowing each unit's description to get a column's width in points and we check the feasibility if we can consider to add the related API for your need.

Thank you.

Amjad,
Thank you for the quick response. I am currently using Aspose.Cells for Java version 1.9.5, but I am unable to use the Cells.getColumnWidthPixel() method for some reason. The compiler says no method exists, is it used the same way as Cells.getColumnWidth()? For example,

public float getColumnWidthPixel(int columnIndex);

Thank you again for the help.

-Chad

Hi Chad,

Could you try the attached version (fix) for Java 1.9.5.9, it includes the Cells.getColumnWidthPixel(int colIndex). Confirm us if it works fine now.

Thank you.

Amjad,
I can confirm that both getColumnWidthPixel() and getRowHeightPixel() are working properly. Thank you again for your timely response and support, I am very much looking forward to doing business with you and your company in the future.

-Chad