0

My application is generating a CSV file which opens in Microsoft excel and Notepad++ correctly. But fails to open in Vim (linux text editor). I tried multiple ways to generate this csv but it does not show the data in vim correctly.

If i open that CSV in excel and again save it as csv extension then only it works in vim application.

My current code is as follows -

 Response.ContentType = "application/vnd.ms-excel";
 Response.AddHeader("content-disposition", "attachment; filename=mytest.csv");
 Response.BufferOutput = true;
 Response.OutputStream.Write(doc.File_Stream, 0, doc.File_Stream.Length);
 Response.End();

I tried below code as well

Response.ContentType = "text/csv";
Response.AddHeader("content-disposition", "attachment; filename=myTest.csv");
Response.BufferOutput = true;
Response.OutputStream.Write(doc.File_Stream, 0, doc.File_Stream.Length);
Response.End();

still not working with VIM. It shows the output of file as follows

enter image description here

omkar patade
  • 1,442
  • 9
  • 34
  • 66
  • What "fails" in vi? Is there an error message? – David Fox Feb 24 '20 at 15:42
  • @DavidFox Not error message but it does not show any data in correct format when i open it in vim. i have added the screen shot in question – omkar patade Feb 24 '20 at 15:45
  • @omkarpatade, take a look at [this other post](https://stackoverflow.com/questions/1229900/reformat-in-vim-for-a-nice-column-layout). I believe it will solve your problem. – diogoslima Feb 24 '20 at 15:49

1 Answers1

0

Performing Encoding.Utf8 conversion on byte array done the trick

omkar patade
  • 1,442
  • 9
  • 34
  • 66