Exporting the values in List to excel

后端 未结 12 1447
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 18:36

Hi I am having a list container which contains the list of values. I wish to export the list values directly to Excel. Is there any way to do it directly?

12条回答
  •  情话喂你
    2020-12-05 19:13

    Using the CSV idea, if it's just a list of Strings. Assuming l is your list:

    using System.IO;
    
    using(StreamWriter sw = File.CreateText("list.csv"))
    {
      for(int i = 0; i < l.Count; i++)
      {
        sw.WriteLine(l[i]);
      }
    }
    

提交回复
热议问题