Click here to Skip to main content
15,916,941 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How can I increase the row height of excel row from vb.net code?
I have this code which is not working. No error is coming.
Width section is working fine..

VB
Dim _xl As New Excel.Application
           Dim _xlBook As Excel.Workbook
          Dim _xlSheet1 As Excel.Worksheet 
          _xlSheet1.Rows("1:1").rowheight = 100
           _xlSheet1.Columns(1).ColumnWidth = 15
           _xlSheet1.Columns(2).ColumnWidth = 34
Posted

Have you tried this with:

VB
Dim _xl As New Excel.Application
Dim _xlBook As Excel.Workbook
Dim _xlSheet1 As Excel.Worksheet

_xlSheet1.Rows(1).RowHeight = 100 ' This will set the height for row number 1
_xlSheet1.Columns(1).ColumnWidth = 15
_xlSheet1.Columns(2).ColumnWidth = 34


Hope that helps!

Regards,

Manfred
 
Share this answer
 
Comments
Rahul K Singh 10-Aug-12 6:59am    
No... its not working.. i have Googled a lot.. it is also giving the similar solution... but it is not working for me...
Kenneth Haugland 10-Aug-12 9:47am    
Look here:
http://msdn.microsoft.com/en-us/library/office/ff196952.aspx

What MAnfred showed you is how you are supposed to do this, if it does not solve your problem, then you did something else wrong. I personally think it has to do with the range you are inserting in the row...
Maciej Los 10-Aug-12 16:11pm    
It's not working, because your code is not complete. See my answer.
VB
Dim _xl As New Excel.Application
Dim _xlBook As Excel.Workbook
Dim _xlSheet1 As Excel.Worksheet

_xlBook  = _xl.Workbooks.Open("fullpathtothefile.xls") 'or: New Workbook
_xlSheet1 = _xlBook.WorkSheets(1) 'or _xlBook.WorkSheets("NameOfSheet")

_xlSheet1.Rows("1:1").RowHeight = 100
_xlSheet1.Columns(1).ColumnWidth = 15
_xlSheet1.Columns(2).ColumnWidth = 34


Do you see the difference?
 
Share this answer
 
Comments
Kenneth Haugland 10-Aug-12 20:03pm    
Ill give you a 5 for that :)
Maciej Los 13-Aug-12 13:14pm    
Thank you, Kenneth ;)
'set the RowHeight=25 of the first row
VB
_xlSheet1.SetRowHeight(1, 25)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900