C# how to iterate over excel columns
c#, excel
Solution
Your loop will looks as follow:
foreach (Excel.Range item in col.Cells)
{
//whatever you want to do with your cells, here- msgbox of cells value
MessageBox.Show(Convert.ToString(item.Value));
}
Problem
I want to get a specific column of an excel sheet and then iterate through it's cells. I want it to look something like this: ``` Excel.Workbook workbook = app.Workbooks.Open(svDropPath); Excel.Worksheet xlWorkSheet = (Excel.Worksheet)workbook.Sheets["Sheet Name"]; var col = xlWorkSheet.UsedRange.Columns["C:C", Type.Missing]; // I want the 3rd column foreach(Cell c in col) .... ``` How do I actually make this foreach loop?