Reputation: 13
I was trying copying a string to an excel line using "\r" to separate the cells. I want only 2 cells to be multiline but using "\n" will switch the text over to the next line in the spreadsheet instead of making a new line in the cell. (The program automaticly copies the text to the Clipboard)
Is there any way to achieve this?
For example if you have a string:
string s = "cell1 \t cell2 \t cell3 \n stillcell3 \t cell4";
It will result in (cell(contents)): A1(cell1) A2(cell2) A3(cell3 newline stillcell3) A4(cell4)
I hope it made sense and it would be great if you could help me!
Solution:
Make sure you have enclosed the multiline section in \"\"
.
Upvotes: 1
Views: 2790
Reputation: 17667
Put the string in memory, using this for example:
String s = "cell1\tcell2\t\"cell3\nstillcell3\"\tcell4\r\n";
Clipboard.SetText(s);
Now go to Excel and Paste the string you generated:
(Control + V)
Upvotes: 2