This project has moved and is read-only. For the latest updates, please go here.

BestFit Column widths.

Jan 20, 2011 at 8:54 AM

I am creating a worksheet that has a column with some wide strings in it. I would like the column width tp be set so that all of the data within the column is shown. (i.e. The same as double clicking on the column separator within Excel ).

I assumed that I could use code like :

worksheet.Column(1).BestFit = true;

but this does not seem to work, the column is not resized. 

I tried adding this code before I populate the worksheet, and then again afterwards - but neither seem to work.

Can anyone point out where I am going wrong.



Jan 20, 2011 at 7:14 PM


The bestfit property don't autosize the column (when set to true, it expands the width of the column when a user writes in a cell).

There is no autosize of columns in the library at the moment, but this thread might be helpful...