-
Notifications
You must be signed in to change notification settings - Fork 136
QuickCSVWrite
Cinchoo edited this page Jan 9, 2022
·
11 revisions
To generate CSV file, use the ChoCSVWriter component to generate it. Sample below shows how to create CSV file (Emp.csv)
1,Mark
2,Jason
List<ExpandoObject> objs = new List<ExpandoObject>();
dynamic rec1 = new ExpandoObject();
rec1.Id = 1;
rec1.Name = "Mark";
objs.Add(rec1);
dynamic rec2 = new ExpandoObject();
rec2.Id = 2;
rec2.Name = "Jason";
objs.Add(rec2);
using (var parser = new ChoCSVWriter("Emp.csv"))
{
parser.Write(objs);
}
using (var parser = new ChoCSVWriter("Emp.csv"))
{
dynamic rec1 = new ExpandoObject();
rec1.Id = 1;
rec1.Name = "Mark";
parser.Write(rec1);
dynamic rec2 = new ExpandoObject();
rec2.Id = 2;
rec2.Name = "Jason";
parser.Write(rec2);
}
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
}
List<Employee> objs = new List<Employee>();
objs.Add(new Employee() { Id = 1, Name = "Tom" });
objs.Add(new Employee() { Id = 2, Name = "Mark" });
using (var parser = new ChoCSVWriter<Employee>("Emp.csv"))
{
parser.Write(objs);
}
Please visit below article for detailed walk-through of CSV writer
©2017 Cinchoo Inc