public static double Pixel2ColumnWidth(this ExcelWorksheet ws, int pixels)
{
//The correct method to convert pixel to width is:
//1. use the formula =Truncate(({pixels}-5)/{Maximum Digit Width} * 100+0.5)/100
// to convert pixel to character number.
//2. use the formula width = Truncate([{Number of Characters} * {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256
// to convert the character number to width.
//get the maximum digit width
var mdw = ws.Workbook.MaxFontWidth;
//convert pixel to character number
var numChars = decimal.Truncate(decimal.Add((pixels - 5) / mdw * 100, (decimal)0.5)) / 100;
//convert the character number to width
var excelColumnWidth = decimal.Truncate((decimal.Add(numChars * mdw, 5)) / mdw * 256) / 256;
return Convert.ToDouble(excelColumnWidth, CultureInfo.InvariantCulture);
}