Below is the code to fetch the value of dropdown in Excel sheet and to send the value to Excel sheet using C#.
using System;
using Excel = Microsoft.Office.Interop.Excel;
namespace Purush_Excel
{
class Purush_Excel_Dropdown
{
static void Main(string[] args)
{
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"C:\Purush\Test.xlsx");
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets["Purush_Sheet1"];
Excel.Range xlRange =
xlWorksheet.UsedRange;
var DropDownCell = xlWorksheet.get_Range("S2", Type.Missing);
var DropDownCellCurrentValue = DropDownCell.Value2;//GET Excel Dropdown Value
DropDownCell.Value2="Company 1";//SET Excel Dropdown Value
xlWorkbook.Save();
xlWorkbook.Close();
}
}
0 comments: