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
1285
Multiline Cell
posted

How do I put a carriage return in a cell? 

Currently I tried this: String.Format("{0}\r\nLabor Category", contract.Agency.Name);
But it just butts the string together.

 

Thanks

Parents
No Data
Reply
  • 440
    posted

    Hi,

    in Excel pressing Alt + Enter inserts what is called a Line Feed character. This automatically sets the “Warp text” option on the format of the cell.

    When you’ve exported to Excel you’ve set the line feed character ("Line 1" + (char)10 + "Line 2"), but the “warp text” of these cells is not set. That’s why the strings look “butted”. To prove that you can try to open the excel file and put the cell with “butted” content in edit mode. Then leave the cell and Excel will set the Warp mode and it will warp the contents.

Children
No Data