Click here to Skip to main content
15,891,993 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i am trying to fetch the details from the 2nd sheet of excel and load the values into the combobox. Once the user selects the value fromn the combobox it will be saved in the 1st sheet of excel. I am finding difficulty in loading the values into the combobox by fetching it from the 2nd sheet of excel.

Job PO Code
Select NA NA
ABC 3818 1322548
DEF 3818 312817

Above is the format stored in the 2nd sheet of excel. This should automatically load to the combobox of winforms.

Thanks in Advance.

What I have tried:

C#
for (int index = 2; index <= lastRow; index++)
{
    System.Array MyValues = (System.Array)MySheet.get_Range("A" + index.ToString(), "L" + index.ToString()).Cells.Value;

    EmpList.Add(new Employee
    {
        SAPID = MyValues.GetValue(1, 1).ToString(),
        EmployeeName = MyValues.GetValue(1, 2).ToString(),
        ISN = MyValues.GetValue(1, 3).ToString(),
        Name = MyValues.GetValue(1, 4).ToString(),
        Onsite_Offshore = MyValues.GetValue(1, 5).ToString(),
        Description = MyValues.GetValue(1, 6).ToString(),
        PO = MyValues.GetValue(1, 7).ToString(),
        Code = MyValues.GetValue(1, 8).ToString(),
        WeeklyHours = MyValues.GetValue(1, 9).ToString(),
        End_Date =Convert.ToDateTime(MyValues.GetValue(1, 10)),
        NoOfLeaves = Convert.ToInt32(MyValues.GetValue(1, 11)),
        Remarks = MyValues.GetValue(1, 12).ToString()
    });
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900