Insert Sheet Rows in Excel Addin C#

Insert Rows:

Adding new row in Excel using code. In this article we will learn how to insert new row in Excel sheet using VSTO (Visual Studio Tools for Office) C# code.

Prerequisites:

  • Visual Studio 2015 or above having Microsoft Office for Developer Tool installed
  • Create Excel Addin in C# code style (Visual Studio Tools for Office)
  • Create a ribbon designer and put button

Code Example:

private void btnInsertSheetRows_Click(object sender, RibbonControlEventArgs e)
{
	//capture user selection
	excel.Range oRange = Globals.ThisAddIn.Application.Selection;
	//Adding new row
	oRange.EntireRow.Insert();
}

Output Example:

Before code execution:

Post code execution:

Please leave your valuable comments!!!

Next: Add new column in Excel using VSTO C#

Leave a Reply

Your email address will not be published. Required fields are marked *