Hi, can someone please tell me or point me in the right direction regarding how to save a LINQ table to an excel spreadsheet?
Thanks!
Mr Cricket
Hi, can someone please tell me or point me in the right direction regarding how to save a LINQ table to an excel spreadsheet?
Thanks!
Mr Cricket
Generally, there are two methods to Excel:
UI layer
A lot of UI controls, say Grids, such as XtraGrid (DevExpress.com), can show Linq result (actually you have to call IQueryable.ToList() at first) and then export what you see into excel, pdf, csv and other formats.
The advantage is you may adjust the UI represenation of the Linq data before you export it. The disadvantage is that it is interactive, so user activity is involved.
Data Layer
You may write lines of code to export the data into MS excel directly. It should be very easy if you know the API of MS API. But if you want to make the sheet beautiful, you may need a lot of code. Or you may create an MS Excel template manually and show the data by the help of the template.
The advantage is the speed and no user is involved. The disadvantage is that it is hard to make the export beautiful or conveniently. Especially when you offer this function to end users.