Export a list of LINQ objects to Excel file

前端 未结 3 604
一整个雨季
一整个雨季 2021-02-10 22:21

From a web application, is there a simple way to export a list of LINQ objects to an Excel file? Are there any good libraries that can do this?

3条回答
  •  执笔经年
    2021-02-10 22:43

    Check out the VB team's videos linked from the ASP.Net, Beth Massi actually does a very similar demo that might do what you want:

    http://www.asp.net/linq/videos/how-do-i-create-excel-spreadsheets-using-linq-to-xml

    You might find others in the same series useful, they are here about 4/5 down the page:

    http://www.asp.net/web-forms/data

    There is also a project called Linq-To-Excel which is here - http://code.google.com/p/linqtoexcel/

    Or you could use the OpenXML libraries to do this sort of thing, here is one such example - http://msdn.microsoft.com/en-us/library/bb508943(v=office.12).aspx

    Excel can also open XML files directly, so you could just create an XML output using XML serialisation or whatever other method, and open it in Excel.

提交回复
热议问题