2
I have the following code that inserts a value in an excel cell for export
context.Response.Write("aa\r\nbb\r\nccc");
/r/n breaks the line but writes in the cell below, would like to break the line but continue with the text in the same cell. How should I do?
Here is the full code
HttpContext context = HttpContext.Current;
context.Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1");
context.Response.Charset = "UTF-8";
context.Response.ContentType = "text/csv";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=teste.csv");
context.Response.Write("aa\r\nbb\r\nccc");
context.Response.End();
Use the ALT+Enter key escape
– Roger Barretto
What is the context of the code presented? This seems to me a request being processed on the server... how could this stop in an excel table? Add more details on the question.
– Miguel Angelo
I agree with @Miguelangelo, this scenario presented seems that you are opening a text file in excel with a contenttype = "application/excel". This way I suggest you create a <table> break the text inside the <TD> and display as excel content.
– Roger Barretto
I edited the question with the context
– Pedro Giorgis