简体   繁体   中英

How to edit excel row values using c#

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.

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());
}

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM