I have a table of data which i need to read from excel based on user input and store it in VS as an array.
If the user enters C1, search and get the associated data:
array[0]: X1E1M101
array[1]: F2G1M202
If the user enters C2:
array[0]: X1E1M105
array[1]: F1G2M304
my data:
A B C D E
1 C1
2
3 X1 E1 M1 01
4 F2 G1 M2 02
5
6 C2
7
8 X1 E1 M1 05
9 F1 G2 M3 04
10
my code:
//I declared the Interop
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
Excel.Range range;
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(ManufacturingFile);
//xlWorkSheet = ("Default Value"); // i get an error here when trying to define the worksheet name i want to select. "Cannot impicitly convert type string to ... excel.worksheet'
xlWorkSheet = ((Excel.Worksheet)this.Application.ActiveWorkbook.Sheets[1]).Select(); // This method also I get an error.
xlWorkSheet.Activate();
I am stuck after this part as I am new to using Interop. Hope someone can help me, I am a beginner in C# and your help is much appreciated.