Exporting datagridview to csv file

后端 未结 8 1848
南方客
南方客 2020-11-29 10:11

I\'m working on a application which will export my DataGridView called scannerDataGridView to a csv file.

Found some example code to do this, but can\'t get it worki

8条回答
  •  醉话见心
    2020-11-29 10:51

    The line "csvFileWriter.WriteLine(dataFromGrid);" should be moved down one line below the closing bracket, else you'll get a lot of repeating results:

    for (int i = 1; i <= countColumn; i++)
    {
    dataFromGrid = dataFromGrid + ',' + dataRowObject.Cells[i].Value.ToString();
    }
    csvFileWriter.WriteLine(dataFromGrid);
    

提交回复
热议问题