private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Image image = Image.FromFile(@"F:\Generic Basketball Score Sheet-1.png"); List <Player> listPlayer = PlayerHelper.GetPlayer(tournament); List <Player> playerByTeam = Player.PlayerByTeam(listPlayer, match.homeTeam.teamID); List <TeamOfficial> listOfficial = TeamOfficialHelper.GetAllOfficial(tournament); var official = TeamOfficial.ShowByTeam(listOfficial, match.homeTeam.teamID); //HEADER GAMESCORESHEET e.Graphics.DrawImage(image, e.PageBounds); e.Graphics.DrawString("Abella Vs Tinago", new Font("Courier New", 24, FontStyle.Bold), Brushes.Black, new Point(250, 25)); e.Graphics.DrawString(match.venue.venueName, new Font("Courier New", 11, FontStyle.Regular), Brushes.Black, new Point(700, 85)); //TEAM 1 int counter = 250; e.Graphics.DrawString(match.homeTeam.teamName, new Font("Courier New", 14, FontStyle.Bold), Brushes.Black, new Point(90, 80)); e.Graphics.DrawString(official.firstName + " " + official.lastName, new Font("Courier New", 14, FontStyle.Bold), Brushes.Black, new Point(80, 215)); foreach (var pl in playerByTeam) { e.Graphics.DrawString(pl.firstName + " " + pl.lastName, new Font("Courier New", 11, FontStyle.Bold), Brushes.Black, new Point(25, counter)); e.Graphics.DrawString(pl.jerseyNO.ToString(), new Font("Courier New", 11, FontStyle.Bold), Brushes.Black, new Point(290, counter)); counter += 20; } //TEAM 2 counter = 725; playerByTeam = Player.PlayerByTeam(listPlayer, match.guestTeam.teamID); foreach (var pl in playerByTeam) { e.Graphics.DrawString(pl.firstName + " " + pl.lastName, new Font("Courier New", 10, FontStyle.Bold), Brushes.Black, new Point(25, counter)); e.Graphics.DrawString(pl.jerseyNO.ToString(), new Font("Courier New", 11, FontStyle.Bold), Brushes.Black, new Point(290, counter)); counter += 18; } }
private void ExportTeamRooster() { var tournament = new Tournament(); int si = 0; try { si = lvwTournaments.SelectedItems[0].Index; } catch { return; } tournament = list[si]; List <Team> team = TeamHelper.GetTeam(tournament); List <Player> player = PlayerHelper.GetPlayer(tournament); List <TeamOfficial> official = TeamOfficialHelper.GetAllOfficial(tournament); ExcelPackage ExcelPkg = new ExcelPackage(); ExcelWorksheet wsSheet1 = ExcelPkg.Workbook.Worksheets.Add("Sheet1"); wsSheet1.Cells.Style.Font.Name = "Arial Narrow"; wsSheet1.Cells.Style.Font.Size = 11; //Title Of tournament wsSheet1.Cells["G" + 3].Value = "Basketball Tournament 2018"; //Date of tournament wsSheet1.Cells["G" + 4].Value = "April 15, 2018 - April 25, 2018"; wsSheet1.Cells["G9"].Value = "Official Team Rooster"; wsSheet1.Cells["G9"].Style.Font.Name = "Times New Roman"; wsSheet1.Cells["G9"].Style.Font.Size = 14; //Header of Tournament wsSheet1.Cells["A11"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; wsSheet1.Cells["A11"].Value = "NO.1"; wsSheet1.Cells["C11"].Value = "Team name"; wsSheet1.Cells["G11"].Value = "Head Coach"; wsSheet1.Cells["K11"].Value = "Jersey No."; wsSheet1.Cells["N11"].Value = "Players"; int rowIndex = 0; int colIndex = 1; int Height = 220; int Width = 120; Image img = Image.FromFile(@"C:\Users\JOSHUA\Documents\Visual Studio 2015\Projects\BATMAN\Images\seal.jpg"); ExcelPicture pic = wsSheet1.Drawings.AddPicture("Sample", img); pic.SetPosition(rowIndex, 0, colIndex, 0); //pic.SetPosition(PixelTop, PixelLeft); pic.SetSize(Height, Width); string fileName = @"C:\Users\JOSHUA\Documents\Visual Studio 2015\Projects\BATMAN\" + wsSheet1.Cells["G" + 3].Value.ToString() + ".xls"; //INITIALIZING COUNTER FOR CELL int NoCounter = 12; int numberCounter = 1; int ctr = 12; foreach (var t in team) { var playerByTeam = BATMAN.Classes.Player.PlayerByTeam(player, t.teamID); var officialByTeam = TeamOfficial.ShowByTeam(official, t.teamID); wsSheet1.Cells["C" + NoCounter].Value = t.teamName; wsSheet1.Cells["G" + NoCounter].Value = officialByTeam.firstName + " " + officialByTeam.lastName; wsSheet1.Cells["A" + NoCounter].Value = numberCounter++; wsSheet1.Cells["A" + NoCounter].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; foreach (var p in playerByTeam) { wsSheet1.Cells["K" + ctr].Value = p.jerseyNO.ToString(); wsSheet1.Cells["N" + ctr++].Value = p.firstName + " " + p.lastName; NoCounter++; } ctr++; NoCounter++; } wsSheet1.Protection.IsProtected = false; wsSheet1.Protection.AllowSelectLockedCells = false; ExcelPkg.SaveAs(new FileInfo(fileName)); FileInfo fi = new FileInfo(fileName); if (fi.Exists) { System.Diagnostics.Process.Start(fileName); } else { MessageBox.Show("Theres a problem while opening excel,Go to " + fileName + "Manual Open"); } }