我能够将单个值保存到 Excel 中,但我需要帮助将完整列表/数组保存到 Excel 工作表中。
我到目前为止的代码:
var MovieNames = session.Query<Movie>()
.ToArray();
List<string> MovieList = new List<string>();
foreach (var movie in MovieNames)
{
MovieList.Add(movie.MovieName);
}
//If I want to print a single value or a string,
//I can use the following to print/save to excel
// How can I do this if I want to print that entire
//list thats generated in "MovieList"
return File(new System.Text.UTF8Encoding().GetBytes(MovieList), "text/csv", "demo.csv");
最佳答案
您可以使用FileHelpers将一些强类型对象序列化为 CSV。只要答应我never roll your own CSV parser .
关于c# - 在 C# 中打印数组/列表到 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8811470/