I'm not sure it's possible to set a column to autofit, from the docs:
"The width corresponds to the column width value that is specified in Excel. It is approximately equal to the length of a string in the default font of Arial 10. Unfortunately, there is no way to specify "AutoFit" for a column in the Excel file format. This feature is only available at runtime from within Excel."
Update: Given that you can determine the maximum string length perhaps you could try adding some padding depending on the font/size being used.
In reply to Re: WriteExcel dynamic width
by marto
in thread WriteExcel dynamic width
by ag4ve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |