public static void ExportCSV(string filePath, object data) { using (var writer = new StreamWriter(System.IO.Path.GetFullPath(filePath))) { //TODO cast object to list foreach (var line in (System.Collections.IList)data) { int count = 0; if (MainTools.IsList(line)) { var t = line.GetType(); var l = (System.Collections.IList)line; foreach (var entry in l) { writer.Write(MainTools.Quoted((entry ?? "").ToString().Replace("\n", string.Empty))); if (++count < l.Count) { writer.Write(","); } } writer.WriteLine(); } else { writer.Write(MainTools.Quoted((line ?? "").ToString().Replace("\n", string.Empty))); writer.Write(","); writer.WriteLine(); } } } }