private void WriteTeamRows(Standings standings, ISheet sheet) { int rowNum = 1; foreach (var team in standings.Divisions[0].Teams) { int column = 0; IRow row = sheet.CreateRow(rowNum); var cell = row.CreateCell(column); cell.SetCellValue(team.Id.ToString()); column++; cell = row.CreateCell(column); cell.SetCellValue(team.Name); column++; cell = row.CreateCell(column); cell.SetCellValue(team.PointsFor.Formatted); column++; cell = row.CreateCell(column); cell.SetCellValue(team.PointsAgainst.Formatted); column++; cell = row.CreateCell(column); cell.SetCellValue(team.RecordOverall.Wins.GetValueOrDefault()); column++; cell = row.CreateCell(column); cell.SetCellValue(team.RecordOverall.Losses.GetValueOrDefault()); column++; cell = row.CreateCell(column); cell.SetCellValue(team.RecordOverall.Rank.ToString()); column++; cell = row.CreateCell(column); cell.SetCellValue(team.RecordPostseason.Wins.GetValueOrDefault()); column++; cell = row.CreateCell(column); cell.SetCellValue(team.RecordPostseason.Losses.GetValueOrDefault()); column++; cell = row.CreateCell(column); cell.SetCellValue(team.RecordPostseason.Rank.ToString()); column++; cell = row.CreateCell(column); cell.SetCellValue(team.Streak.Formatted); column++; cell = row.CreateCell(column); cell.SetCellValue(team.DraftPosition.ToString()); column++; rowNum++; } }
public async Task ExecuteAsync(IProgress <string> progress, IProgress <string> importComplete) { //https://www.fleaflicker.com/api-docs/index.html _reportProgress = progress; _reportProgress.Report($"Starting download..."); string url = $"https://www.fleaflicker.com/api/FetchLeagueStandings?sport=NFL&league_id={_leagueID}&season={_season}"; var jsonResult = await client.GetStreamAsync(url); Standings standings = DeserializeCompressed <Standings>(jsonResult); //iterate each team in divicion[0], put team id, name into sheet 1 of new excel workbook //then call https://www.fleaflicker.com/api/FetchLeagueScoreboard?sport=NFL&league_id=295664&season=2019&scoring_period=1 //for each scoring period, get data for the scoring period, output game info //each weeks games in new sheet var currentDirectory = Directory.GetCurrentDirectory(); var fullFilePath = Path.Combine(currentDirectory, $"{_season}LeageData.xlsx"); using (FileStream stream = new FileStream(fullFilePath, FileMode.Create, FileAccess.Write)) { IWorkbook wb = new XSSFWorkbook(); ISheet teamSheet = wb.CreateSheet("Teams"); WriteTeamHeaderRow(teamSheet); WriteTeamRows(standings, teamSheet); await WriteScores(wb); for (int i = 0; i < 12; i++) { teamSheet.AutoSizeColumn(i); } wb.Write(stream); } importComplete.Report(fullFilePath); return; }