Esempio n. 1
0
        public string Ranks()
        {
            string   file_out     = "Выполнение разрядных норм " + DateTime.Today.ToShortDateString() + ".xlsx";
            string   file_in      = "разрядные нормы.xlsx";
            FileInfo newFile      = Utils.GetFileInfo(file_out);
            FileInfo templateFile = new FileInfo($"{AppDomain.CurrentDomain.BaseDirectory}шаблоны" + Path.DirectorySeparatorChar + file_in); //Utils.GetFileInfo(file_in, false);

            using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                worksheet.Name = "разрядные нормы";
                package.Workbook.Properties.Author         = "Тавлея";
                package.Workbook.Properties.LastModifiedBy = "Тавлея";
                worksheet.Cells["A2"].Value = tvlData.tournir_name;
                worksheet.Cells["A3"].Value = tvlData.tournir_start_date + " - " + tvlData.tournir_finish_date + " " + tvlData.tournir_place;
                for (int i = 4; i < tvlData.players.Count - 2 + 4; i++)//add columns for opponents
                {
                    worksheet.InsertColumn(i, 1, i - 1);
                    worksheet.Cells[5, i].Value = i - 2;
                }

                for (int i = 3; i < tvlData.players.Count - 1 + 4; i++)//set optimal columns width
                {
                    worksheet.Column(i).Width = 65 / tvlData.players.Count;
                }

                worksheet.Cells[4, 3, 4, tvlData.players.Count + 1].Merge = true;//merge opponents header

                int up_shift = 5;
                worksheet.InsertRow(up_shift + 2, tvlData.players.Count - 1, up_shift + 1);//insert frmatted rows for players
                for (int pl_num = 0; pl_num < tvlData.players.Count; pl_num++)
                {
                    player pl = tvlData.players[pl_num];

                    worksheet.Cells[pl_num + 1 + up_shift, 1].Value = pl.id;
                    worksheet.Cells[pl_num + 1 + up_shift, 2].Value = pl.fio();

                    for (int i = 3; i < 3 + tvlData.players.Count - 1; i++)//results (points)
                    {
                        worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.players[MainForm.search_by_id(pl.opponents[i - 3])].rank;
                    }
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 3].Value = pl.rank_INDEX; //необх кт
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 4].Value = pl.rank_coeft; //турн кт
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 5].Value = pl.point_norm; //норма очков
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 6].Value = pl.points;     // очки
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 7].Value = pl.rank;       //разр до
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 8].Value = pl.new_rank;   //разр после
                    if (pl.rank_UP == 1)
                    {
                        worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 8].Style.Font.Color.SetColor(System.Drawing.Color.Green);
                    }
                    if (pl.rank_UP == -1)
                    {
                        worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count - 1 + 8].Style.Font.Color.SetColor(System.Drawing.Color.Red);
                    }
                }
                worksheet.Cells[tvlData.players.Count + up_shift + 3, 5].Value = tvlData.tournir_main_judge;
                worksheet.Cells[tvlData.players.Count + up_shift + 5, 5].Value = tvlData.tournir_secretary;
                // save our new workbook and we are done!
                package.Save();
                Process.Start(Utils.OutputDir.FullName + Path.DirectorySeparatorChar + file_out);
            }
            return(newFile.FullName);
        }
Esempio n. 2
0
        private void Round_report2()
        {
            string   file_out     = "Турнир " + DateTime.Today.ToShortDateString() + " (КРУГОВАЯ).xlsx";
            string   file_in      = "круговая2.xlsx";
            FileInfo newFile      = Utils.GetFileInfo(file_out);
            FileInfo templateFile = new FileInfo($"{AppDomain.CurrentDomain.BaseDirectory}шаблоны" + Path.DirectorySeparatorChar + file_in); //Utils.GetFileInfo(file_in, false);

            using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                worksheet.Name = "Тавлея (круговая)";
                package.Workbook.Properties.Author         = "Тавлея";
                package.Workbook.Properties.LastModifiedBy = "Тавлея";
                worksheet.Cells["A2"].Value = tvlData.tournir_name;
                worksheet.Cells["A3"].Value = tvlData.tournir_start_date + " - " + tvlData.tournir_finish_date + " " + tvlData.tournir_place;
                for (int i = 6; i < tvlData.players.Count - 1 + 6; i++)//add columns for opponents
                {
                    worksheet.InsertColumn(i, 1, i - 1);
                    worksheet.Cells[5, i].Value = i - 4;
                }

                for (int i = 5; i < tvlData.players.Count - 1 + 6; i++)//set optimal columns width
                {
                    worksheet.Column(i).Width = 65 / tvlData.players.Count;
                }

                worksheet.Cells[4, 5, 4, tvlData.players.Count + 4].Merge = true;//merge opponents header

                int up_shift = 5;
                worksheet.InsertRow(up_shift + 2, tvlData.players.Count - 1, up_shift + 1);//insert frmatted rows for players
                for (int pl_num = 0; pl_num < tvlData.players.Count; pl_num++)
                {
                    player pl = tvlData.players[pl_num];

                    worksheet.Cells[pl_num + 1 + up_shift, 1].Value = pl.id;
                    worksheet.Cells[pl_num + 1 + up_shift, 2].Value = pl.fio();
                    worksheet.Cells[pl_num + 1 + up_shift, 3].Value = pl.year;
                    worksheet.Cells[pl_num + 1 + up_shift, 4].Value = pl.rank;
                    for (int i = 5; i < 5 + tvlData.players.Count; i++)//results (points)
                    {
                        foreach (int g in pl.games)
                        {
                            if ((tvlData.games[g - 1].first == pl.id) && (tvlData.games[g - 1].second == i - 4))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt1;
                            }
                            if ((tvlData.games[g - 1].second == pl.id) && (tvlData.games[g - 1].first == i - 4))
                            {
                                worksheet.Cells[pl_num + 1 + up_shift, i].Value = tvlData.games[g - 1].pt2;
                            }
                        }
                    }
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 5].Value = pl.points;
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 6].Value = pl.coef[2];
                    worksheet.Cells[pl_num + 1 + up_shift, tvlData.players.Count + 7].Value = pl.place;
                }
                worksheet.Cells[tvlData.players.Count + up_shift + 3, 5].Value = tvlData.tournir_main_judge;
                worksheet.Cells[tvlData.players.Count + up_shift + 5, 5].Value = tvlData.tournir_secretary;
                // save our new workbook and we are done!
                package.Save();
                Process.Start(Utils.OutputDir.FullName + Path.DirectorySeparatorChar + file_out);
            }
        }