0

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);
 }
Liath
  • 9,913
  • 9
  • 51
  • 81
  • possible duplicate of [How to convert a column number (eg. 127) into an excel column (eg. AA)](http://stackoverflow.com/questions/181596/how-to-convert-a-column-number-eg-127-into-an-excel-column-eg-aa) – user1767754 Feb 10 '14 at 08:07

1 Answers1

0

See How to convert a- column number eg. 127 into an Excel column eg. AA here on Stackoverflow

Community
  • 1
  • 1
user1767754
  • 23,311
  • 18
  • 141
  • 164