0
I saw an example of code right here in stackoverflow where I use the example below to write a CSV file using stringbuilder:
public void ExportarCsv(List<Result> erros)
{
string filename = "resultado.csv";
string path = @"C:\Arquivo\";
Console.WriteLine("Escrevendo no arquivo.");
StringBuilder csvBuilder = new StringBuilder();
//cria o header
csvBuilder.AppendLine("Order;Motivo");
foreach (var item in erros)
{
csvBuilder.AppendLine(item.CodigoPedido);
}
if (!Directory.Exists(path))
{
DirectoryInfo di = Directory.CreateDirectory(path);
}
File.WriteAllText(path + filename, csvBuilder.ToString(), Encoding.UTF8);
}
In this example I have the heading Order and Reason, but I can only write below the Order. How do I write the values in each column respectively ?
good thank you very much. Very simple, I was not able to see, thanks for the light kkkk
– Desalex