i have a list of multiple objects that I want to write into an excel sheet. I create a folder and filename, following the path and the writer:
string path = Path.Combine(folder, fileName);
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
HasHeaderRecord = true
};
using (var writer = new StreamWriter(path))
using (var csv = new CsvWriter(writer, config))
{
csv.WriteRecords(outputYearlyResult);
}
It does write to an excel sheet, also with the data I want. However, it adds a lot more columns than parameters in OptResultYear. The columns are not strange, they are from another database, but I don’t know how they could enter here? I’ve checked and the dictionaries only contain the parameters that I filled in and nothing more.
How do I reduce the columns it prints?
Please note, that the excel sheet is furthermore exactly as I expected, just with additional columns.
Markje is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.