How to edit excel row values using c#

341 views Asked by At

I'm importing the excel files using import button and displaying them in the datagridview. Now when i click at apply button, i want the first letter of the row values(highlighted in the attached image) to be capitalized (there can be multiple rows/values).

eg: peter joe ===> Peter Joe

How can i edit these values.

I'm a beginner, would be great if anyone can help with this.

1

There are 1 answers

4
Caius Jard On BEST ANSWER

This isnt really anything to do with editing excel row values (per the title) but..

You have an apply button click event handler that enumerates the datatable and sets the values:

private void applyButton_Click(object sender, EventArgs e)
{
  TextInfo info = CultureInfo.CurrentCulture.TextInfo;
  DataTable dt = datagridview1.DataSource as DataTable;

  foreach(DataRow r in dt.Select("[SET 1] = 'CUSTOMER'"))
    for(int x = 1; x < r.ItemArray.Length; x++)
      r[x] = info.ToTitleCase(r[x].ToString().ToLower());
}

enter image description here