Search code examples
c#-4.0export-to-excellinqpad

LinqPad - Export to Excel with NO formatting


I found this bit of code to export my data results to Excel:

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); 

This exports the data in Formatted mode. What's the code to replicate just "Export > Export To Excel"?


Solution

  • This functionality is not currently exposed for XhtmlWriter, but there's a WriteCsv method in LINQPad.Util that might do what you want:

    Util.WriteCsv (Customers, @"c:\temp\customers.csv");