How to export linq result to excel just like Linqpad
c#, excel, linq, linqpad
Solution
If you include a reference to linqpad.exe in your project, you can then use it to do the export to html
eg,
List<User> users = ....
var filename = "test.html";
var writer = LINQPad.Util.CreateXhtmlWriter();
writer.Write(users);
System.IO.File.WriteAllText(filename, writer.ToString());
// Open the file in excel
Process.Start("Excel" , filename);
Problem
I have an object with a lot of subqueries and I want do export to excel just like Linqpad does, here is an example: Any help? Tks