Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel auto fit column in VB.NET

Tags:

excel

vb.net

I have here my code in VB6 and its working well.

 For CLms = 1 To 10
      ws.Columns(CLms).AutoFit '<---Autofilt data on XL sheet
 Next CLms

I have searched on what is the equivalent or alternative on how to make the excel columns width autofit in VB.NET, but I'm still not getting the exact AutoFit function.

Any help will be appreciated.

like image 866
user2878699 Avatar asked Dec 09 '22 12:12

user2878699


1 Answers

This is how I've done it in vb.net.

xlSheet.Range("A1:X1").EntireColumn.AutoFit()
like image 79
aphoria Avatar answered Dec 27 '22 00:12

aphoria