Reputation: 1126
I am creating a spreadsheet that collects data from a site and inserts the data into excel. For no reason other than a way for me to follow the data as it fills the sheet with information, is there a way to keep focus on the current cell to force the sheet to scroll (as if clicking the down arrow on the scroll bar) along with the data entry? My current code is as follows:
else if (driver.FindElements(By.XPath("//table[7]/tbody /tr/td[11]")).Count > 0)
{
activesheet.Range["D" + n].Value = driver.FindElement(By.XPath("//table[7]/tbody/tr/td[11]")).Text;
activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
}
I am sure it's very simple, I just have not been able to find this information/command, nor am I sure I am wording my searches correctly or if one even exists.
Upvotes: 1
Views: 611
Reputation: 4010
Use the ScrollRow
property of the ActiveWindow
. If you just want to "hit the down arrow" you can increment.
//app is a valid reference to a Microsoft.Office.Interop.Excel.Application instance
app.ActiveWindow.ScrollRow++;
Reference: https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.window.scrollrow.aspx
Upvotes: 1