private static void CreateExcelFile(ChromeDriver driver) { var upcomingEvents = driver.FindElementsByCssSelector(".event.active"); var wb = new XLWorkbook(); var ws = wb.Worksheets.Add("Games"); ws.Cell("A1").Value = "Games"; ws.Cell("B1").Value = "Home"; ws.Cell("C1").Value = "Draw"; ws.Cell("D1").Value = "Away"; for (int i = 0; i < upcomingEvents.Count; i++) { string eventName = upcomingEvents[i].FindElement(By.ClassName("eventName")).Text; string homeOdd = upcomingEvents[i].FindElement(By.ClassName("home")).Text; string drawOdd = upcomingEvents[i].FindElement(By.ClassName("draw")).Text; string awayOdd = upcomingEvents[i].FindElement(By.ClassName("away")).Text; ws.Cell("A" + (i + 2)).Value = eventName; ws.Cell("B" + (i + 2)).Value = homeOdd; ws.Cell("C" + (i + 2)).Value = drawOdd; ws.Cell("D" + (i + 2)).Value = awayOdd; } // Beautify ws.Range("A1:D1").Style.Font.Bold = true; ws.Columns().AdjustToContents(); wb.SaveAs("../../../../Events.xlsx"); }