Auto column width in EPPlus

.net, c#, epplus, vb.net

Solution

Use `AutoFitColumns`, but you have to specify the cells, i assume the entire worksheet:

VB.NET

Worksheet.Cells(Worksheet.Dimension.Address).AutoFitColumns()

C#

Worksheet.Cells[Worksheet.Dimension.Address].AutoFitColumns();

Please note you need to call this method after filling the worksheet.

Problem

How to make columns to be auto width when texts in columns are long? I use this code ``` Worksheet.Column(colIndex).AutoFitColumn() 'on all columns' Worksheet.cells.AutoFitColumns() Worksheet.Column(colIndex).BestFit = True 'on all columns' ``` None of these methods are working Are there any ways to make it work? Note: Some of my texts use Unicode.

Original source