Excelsheet export Issue?

preeti164

Member
Joined
Oct 27, 2008
Messages
7
Programming Experience
Beginner
Question: I am attempting to force a line break within a cell while generating an excel worksheet from vb.net code. Vbcrlf, Chr(0010), Chr(10), Chr(10) & Chr(13), etc. all push the subsequent text to the next row instead of adding a line break within the cell. What I think I need is the ascii code for the key combination alt+0010 , or alt+enter. I have been looking for this without success... Any ideas?
 
VB.NET:
sheet.Range("A1").Value = "hello" & vbLf & "world"
There is a WrapText property also for the Range, but it was not needed when I tested this.

If you're not doing automation, but perhaps using OleDb then you can use the same string value, but no formatting is applied. If you open the sheet you can add the wrap-text formatting for the cells afterwards and the text displays correctly.
 

Latest posts

Back
Top