Import a specific worksheet from a single excel (CSV) file : <p>I am currently using lumenworks to import data stored within an excel file to my program. It only grabs the information from the first worksheet in the excel document. Would I be able to modify this code in order to import data from a second worksheet, or even all the worksheets at once? Below is what I currently have (imports variables form the main worksheet page):</p>

<pre><code>IWebDriver driver;
    string MyUsername;
    string MyPassword;
    string MySecurityQuestion;
    public LoginPage(IWebDriver driver)
    {
        this.driver = driver;

        string nameColumnName = "Key";
        string valueColumnName = "Username";
        string rowName = "LoginTest";


        //DataTable.Rows[0][0].ToString();
        using (CsvReader csvReader = new CsvReader(new StreamReader("C:/Users/User1/source/repos/DDTesting/DDTesting/TestData.csv"), hasHeaders: true))
        {

            int nameColumnIndex = csvReader.GetFieldIndex(nameColumnName);
            int valueColumnIndex = csvReader.GetFieldIndex(valueColumnName);

            while (csvReader.ReadNextRecord())
            {
                if (csvReader[nameColumnIndex] == rowName)
                {
                    string value = csvReader[valueColumnIndex]; // username

                    MyUsername = value;
                    value = csvReader[valueColumnIndex + 1];
                    MyPassword = value;
                    value = csvReader[valueColumnIndex + 2];
                    MySecurityQuestion = value;
                    break;

                }
            }
        }
    }

        By username = By.Name("username");
        By password = By.Name("password");
        By loginButton = By.ClassName("button-primary");
        By securityQuestion = By.Name("answer");

        public void TypeUsername()
        {

            driver.FindElement(username).Clear();
            driver.FindElement(username).SendKeys(MyUsername);


        }
</code></pre>
