Here’s some simple code to set column width in pixels. I’m setting Column B to 200 pixels and Column C to 700 pixels:
var workbook = new Workbook(); var worksheet = workbook.Worksheets; worksheet.Cells.SetColumnWidthPixel(1, 200); worksheet.Cells.SetColumnWidthPixel(2, 700); workbook.Save(PATH_HERE);
However, the actual width of column B or C changes based on the resolution/size of the monitor I’m using (no joking!) For example, when I run this code from my laptop, Column B is 156 pixels wide and Column C is 544 pixels wide. However, if I dock my laptop (the dock is connected to 2 external monitors), then everything is fine - Column B is 200px and Column C is 700px.
Is there some global setting that I can change so that I always get the specified number of pixels?