I have this code:
context.Response.ClearHeaders();
context.Response.AddHeader("content-disposition", "attachment; filename=Clients.csv");
context.Response.ClearContent();
context.Response.ContentType = "application/ms-excel";
context.Response.ContentEncoding = System.Text.Encoding.Unicode;
context.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
context.Response.BufferOutput = false;
context.Response.Buffer = false;
foreach (var c in clients)
{
context.Response.Output.WriteLine(string.Format("{0},{1}", c.FirstName, c.LastName));
}
The downloaded file looks fine, except the fact that all row cells is merged into one cell. I must use the Response as BinaryWrite because of Hebrew and Japan characters in the csv/xls content. How to write splitted cells csv/xls file with binary write?