Reputation: 167
How can I get the column width in cm? I have already tried a lot of different options, so I ask the question without an example code
Upvotes: 1
Views: 1867
Reputation: 14515
Epplus gives the 'character width' of a column in the .Width
property.
This source suggests a conversion factor of 0.211666, so we can get the cm width as follows:
static void Main(string[] args)
{
var myFileInfo = new FileInfo("input.xlsx");
using (var excel = new ExcelPackage())
{
var worksheet = excel.Workbook.Worksheets.Add("sheet1");
var charWidthOfFirstColumn = worksheet.Column(1).Width;
var widthInCm = charWidthOfFirstColumn * 0.211666;
}
}
Upvotes: 2