Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"?

like image 246
inquisitive_one Avatar asked Jul 03 '13 19:07

inquisitive_one


1 Answers

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");
like image 198
Joe Albahari Avatar answered Oct 29 '22 16:10

Joe Albahari