prepend headers to my csv file

前端 未结 4 439
长发绾君心
长发绾君心 2021-01-29 07:18

I want to prepend headers to my CSV File as to let the data reflect the headings. How would I go about this without having to add it each time writing to the file? Meaning I onl

4条回答
  •  太阳男子
    2021-01-29 07:54

    for (int row_index = 0; row_index <= count_row - 2; row_index++)
    {
        textBox8.Text = textBox8.Text + "\r\n";
    
        for (int cell_index = 1; cell_index <= count_cell - 1; cell_index++)
        {
            textBox8.Text = textBox8.Text + dataGridView1.Rows[row_index].Cells[cell_index].Value.ToString() + ",";
    
        }
    }
    

    Just go to the property pannel of textBox8. Text and add column header with comma and set the textbox8 visibility to hidden.

提交回复
热议问题