1

I want to place Alt+Enter (line break) in a cell in an Excel spreadsheet. How do I write a character which is equivalent to Alt+Enter?

5 Answers 5

1

\n is the escape-sequence for a line-break in a String.

6
  • i know \n as well as \r\n are used for line break. Sep 27, 2011 at 10:14
  • 2
    So what is the problem you're facing? Show some code and be more specific if this is not your solution. Sep 27, 2011 at 10:16
  • it's not for placing line break on screen. I've to put line break in excel sheet and in excel cell if you want to put line break you have to press Alt+Enter. Sep 27, 2011 at 10:16
  • So i guess you're doing this using some kind of API or Library (since your question is tagged with [php]). So, show the code you're using. Sep 27, 2011 at 10:19
  • Yes, I'm using a drupal module which provide a way to convert your data into excel sheet. for this you just need to put column name and it automatically create a excel sheet column. But in my column i wants to split the record by line break. Sep 27, 2011 at 10:23
1

\n is for line break

<br/>is for html break

2
  • Sorry i wasn't able to explane my question properly. Please see the my conversation with Lukas Knuth and respond according to that. Sep 27, 2011 at 10:27
  • try writing this " & # 1 0 " without spaces, and see if it breaks
    – Mob
    Sep 27, 2011 at 10:35
0

For Windows only (you mention Excel) the escape-sequence is \r\n.

0

Try using CHAR(10)

<string1> & CHAR(10) & <string2>

it will produce

<string1>
<string2>

in the excel cell.

0

Please try to insert in following form:

"\="."\"string1\""."&char(10)&"."\"string2\""

After saving it xls through PHP

Apply wrap text on each column where your insert data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.