I have a windows form application in c# where there are list of data in multiple listbox (around 56 in each listbox). here is an example:
- listbox1 contains data of name of students
- listbox2 contains data of address of students
- listbox3 contains percentage of students.
the list goes on with the student data. Now i need to print the data in excel in a button click event. the data should go in an ordered way .
I tried using the CSV helper but it only helped me for 1 set of list box i need to sent data from multiple list box.
var sw = new StreamWriter(@"output.csv");
var csvWriter = new CsvHelper.CsvWriter(sw);
foreach (var Name in lbx.Items)
{
csvWriter.WriteField(Name);
csvWriter.NextRecord();
}
foreach (var Address in ptr.Items)
{
csvWriter.WriteField(Address);
}
sw.Flush();
However, this doesn't solve the problem. Any help regarding the solution to this problem would be helpful. Any other method to solve the problem will be great.