ClosedXML.Excel中的自动调整列

我明白,这个问题愚蠢的,从常见问题,但我不能在自动宽度的Excel列(使用ClosedXML.Excel库)

我的代码:

var wb = new XLWorkbook(); var wsDep = wb.Worksheets.Add("MyWorksheet"); wsDep.Columns("A").AdjustToContents(); wsDep.Columns("B1").AdjustToContents(); wsDep.Columns().AdjustToContents(); 

但没有任何变化。 我如何设置自动宽度列与ClosedXML.Excel库?

您的单元格没有任何内容。因此AdjustToContents()将不起任何作用。