I am creating an application to retrieve the column names into listbox from a particular excel sheet and match the column names with the database columns and insert it into the excel data into table
Can you explain how can I can do it?
Already I have retrieved sheet names into the list box
Microsoft.Office.Interop.Excel.Application app = new ApplicationClass();
Workbook workBook = app.Workbooks.Open(@"your_file_path");
Worksheet workSheet = (Worksheet)workBook.Worksheets.get_Item(1);
Range range = workSheet.UsedRange;
for (int i = 1; i <= range.Columns.Count; i++)
{
ListBox3.Items.Add(((Excel.Range)range.Cells[2, i]).Value2);
}