3.1.1. Excel自动适应列宽

全选所有列再调用AutoFit:


//auto adjust column width (according to content)
Range allColumn = xlWorkSheet.Columns;
allColumn.AutoFit();

        

详见:【已解决】C#中操作刚导出的Excel,设置其为自动调整列宽