我能夠將單個值保存到excel中,但我需要幫助將完整的列表/數組保存到Excel表格中。在c中打印一個數組/列表來優化#
代碼我到目前爲止有:
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");
我得到一個例外 - 「無法訪問已關閉的流」 – ZVenue 2012-01-11 18:04:12
@ZVenue對不起,我忘了,'被佈置在StreamWriter'關閉底層流。我更正了代碼。 – ChrisWue 2012-01-11 18:28:47
謝謝你..這工作。有沒有辦法,我可以使用這種方法格式化輸出?喜歡有多個值輸出和有標籤等.. – ZVenue 2012-01-11 18:40:04