Autofit Column Width

Topics: User Forum
Jan 30, 2011 at 11:26 PM

Is there a way to set the column's width to autofit?

 

 

Jan 16, 2012 at 3:52 PM

WS.Column(1).BestFit = true;

Jun 15, 2012 at 5:16 PM

I get an error when I try to use BestFit:

Error 5 'OfficeOpenXml.ExcelColumn' does not contain a definition for 'BestFit' and no extension method 'BestFit' accepting a first argument of type 'OfficeOpenXml.ExcelColumn' could be found (are you missing a using directive or an assembly reference?)

Someone who knows what directives or an assembly references that are needed?

Jun 26, 2012 at 5:43 PM

Hi

did you find which assembly or reference you had to add

please let me know as I'm stuck

Sep 29, 2013 at 12:30 PM
Use

ws.Columns().AdjustToContents();

hope this will work for you all....
Jul 4, 2014 at 4:31 AM
What is the ws in above solution ?