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

Free Support Forum - aspose.com

How can I set the column width in a spreadsheet to a specific pixel count?

I am setting the width of a column this way:

private static readonly int RESTAURANT_LOCATION_COLUMN_WIDTH = 28;
. . .

The end user wants the width to be precisely 225 pixels.

The width value is obviously not in pixels; is there some calculation for converting the value used to pixels to cause the value assigned to equate to a specific pixel count?


I think you may try to use Cells.SetColumnWidthPixel method to set your desired column’s width in pixels. See the sample code for your reference:
Sample code:

Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[“Sheet1”];
Cells cells = ws.Cells;
//Set the first column (A column) width in the unit of pixels.
cells.SetColumnWidthPixel(0, 225);
Hope, this helps a bit.

Thank you.