简体   繁体   English

如何使用c#编辑excel行值

[英]How to edit excel row values using c#

I'm importing the excel files using import button and displaying them in the datagridview.我正在使用导入按钮导入 excel 文件并将它们显示在 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..这实际上与编辑 excel 行值(根据标题)无关,但是..

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

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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