Related Tags:
C# C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. Learn More, Visual Studio Tools for Office (VSTO) Visual Studio Tools for Office is a set of development tools available in the form of a Visual Studio add-in and a runtime that allows Microsoft Office 2003 and later versions of Office applications to host the .NET Framework Common Language Runtime to expose their functionality via .NET. Learn More, Microsoft Excel Microsoft Excel is a spreadsheet developed by Microsoft for Windows, macOS, Android and iOS. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications. Learn More,

Iterate through a single specified row of an excel sheet using vsto in C# code?

Description:I have a excel sheet and I need to create a list containing all the values of the specified row or specified range!

Posted by: | Posted on: Jan 15, 2020

1 answers

Replies

2

You can simply iterate through a specified row or specified Range by using the following code, in which you can update your range as per your requirement.

List<string> myValue = new List<string>();
foreach (Microsoft.Office.Interop.Excel.Range row in sheet.Cells.Rows.Range["A1","D1"])
{
Microsoft.Office.Interop.Excel.Range cell = (Microsoft.Office.Interop.Excel.Range)row.Cells[1, 1];
if (cell.Value2 != null)
{
myValue.Add(Convert.ToString(cell.Value2));
}
}

Replied by: | Replied on: Jan 16, 2020



Reply