我有這樣的代碼:C#的Response.Write CSV文件不分裂細胞
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));
}
下載的文件看起來不錯,但事實上,所有行單元格合併爲一個單元格。 由於希望和csv/xls內容中的日文字符,我必須使用Response作爲BinaryWrite。 如何使用二進制寫入來寫入拆分單元格csv/xls文件?