Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
29417
How to simulate the ALT-ENTER in excel when adding data
posted
I am creating an Worksheet and attempting to add data to a cell.  I want to pass what Excel uses as alt enter (chr(10)) so that my data shows up as multiple lines within a single cell.  How can this be done? 
Parents
No Data
Reply
  • 29417
    Offline posted


    Hello,

    The new line that get created when you use alt+enter is actually a “/r/n” string when represented as a cell value. So to add such value you just need to add “/r/n” where you need the new line in the cell. So for example:



    cell2.Value = "Sample Text , Sample Text \r\n \r\n \r\n Some more text \r\n Custom text";



    Would generate a text in a cell with new lines. Also keep in mind that the WrapText property needs to be set to true:



    cell2.CellFormat.WrapText = ExcelDefaultableBoolean.True;

     


    Best Regards,


    Maya Kirova


    Developer Support Engineer


    Infragistics, Inc.


    http://ko.infragistics.com/support

Children