I am using a Windows application and I export a datatable into an Excel sheet. It displays successfully. Now I want to have multiple lines in a single cell. How can I do this by using C#?
A:
Take the lines you want and put them into an array, and then join them into a single string, split by the newline character:
String singleCell = String.Join("\n",lines)
and then drop that string into the cell.
daniel
2010-03-12 10:12:32
+1
A:
You can just use "\n" in the String
Excel.Range dataRange= (Excel.Range)excelWorksheet.get_Range("C4", "C4");
dataRange.Value2 = "This is the first line\n" +
"This is the second line\n" +
thirdLineString;
LnDCobra
2010-03-12 10:18:01
Thanks yar... Nice code
Suryakavitha
2010-03-12 10:33:27