Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the values from a column in Excel in uppercase after putting them into a DataTable

Tags:

c#

excel

I am trying to get the values from column 18, Test to uppercase after the upload of the excel file but without any succes.

enter image description here

How exactly can I reach the values that are in a DataTable?

This is where I fill the DataTable with the values from the excel file:

 using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
        {
            DataTable dataTable = new DataTable();
            adapter.Fill(dataTable);
            return dataTable;
        }

I would like to have all the values in 18 to be uppercase.

like image 248
Bayern Avatar asked Nov 23 '25 11:11

Bayern


1 Answers

Loop through all rows making the 18th columns data UpperCase:

foreach (DataRow row in dataTable.Rows)
{
    row["Test"] = row["Test"].ToString().ToUpper();
}
like image 71
Microsoft DN Avatar answered Nov 25 '25 05:11

Microsoft DN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!