init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
948
Kreta.BusinessLogic/Classes/ExcelHelpers/TTFExportHelper.cs
Normal file
948
Kreta.BusinessLogic/Classes/ExcelHelpers/TTFExportHelper.cs
Normal file
|
@ -0,0 +1,948 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.ConnectionType;
|
||||
using Kreta.Resources;
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace Kreta.BusinessLogic.Classes.ExcelHelpers
|
||||
{
|
||||
public class TTFExportHelper : LogicBase
|
||||
{
|
||||
public TTFExportHelper(IConnectionType connectionType) : base(connectionType) { }
|
||||
|
||||
public MemoryStream ExportEgyszeruTTF()
|
||||
{
|
||||
return ExportEgyszeruTTF(null, null, null, null, null, null, null, null, null, null, false, false, false);
|
||||
}
|
||||
|
||||
public MemoryStream ExportEgyszeruTTF(int? tanarId, int? csoportId, int? tantargyId, int? targyKatId, int? foglalkozasTipusId,
|
||||
int? feladatKategoriaId, int? feladatellatasiHelyId, int? evfolyamId, double? oraszam, bool? isImportalt, bool osztalybontasokkal, bool kapcsolodoCsoportokkal, bool isFromSzervezet)
|
||||
{
|
||||
var manager = new ExcelExportManager();
|
||||
var exportFile = new ExcelExportItem();
|
||||
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.Osztaly, ImportExportTantargyfelosztasResource.ImportHeaderNameOsztaly);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.Csoport, ImportExportTantargyfelosztasResource.ImportHeaderNameCsoport);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.Tantargy, ImportExportTantargyfelosztasResource.ImportHeaderNameTantargy);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.Oraszam, ImportExportTantargyfelosztasResource.ImportHeaderNameOraszam);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.Tanar, ImportExportTantargyfelosztasResource.ImportHeaderNameTanar);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.Tuloraszam, ImportExportTantargyfelosztasResource.ImportHeaderNameTulora);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.IsOsszevontOra, ImportExportTantargyfelosztasResource.ImportHeaderNameTtfOraszamKorrekcio);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.IsNemzetisegiOra, ImportExportTantargyfelosztasResource.ImportHeaderNameNemzetisegiOra);
|
||||
exportFile.AddColumn((int)EgyszeruTtfExportColumns.MegbizasiOraszam, ImportExportTantargyfelosztasResource.ImportHeaderNameMegbizasiOraszam);
|
||||
|
||||
var helper = new TantargyFelosztasHelper(ConnectionType);
|
||||
var tantargyIds = tantargyId.HasValue ? new List<int> { tantargyId.Value } : null;
|
||||
var ds = helper.GetTantargyFelosztasData(tanarId, csoportId, tantargyIds, targyKatId, foglalkozasTipusId, feladatKategoriaId, feladatellatasiHelyId, evfolyamId, oraszam, isImportalt, osztalybontasokkal, kapcsolodoCsoportokkal, isFromSzervezet);
|
||||
var rowIndex = 2;
|
||||
|
||||
//NOTE: Erre azért van szükség, ha több egyforma nevű tanár szerepel az adatbázisban, akkor zárójelben mögé tesszük a születési dátumát az export-ban, hogy meg tudjuk őket különböztetni!
|
||||
var tanarDictionary = new Dictionary<string, List<DateTime>>();
|
||||
foreach (var item in ds.Tables[0].AsEnumerable())
|
||||
{
|
||||
var tanarNev = item.Field<string>("Tanar");
|
||||
var tanarSzuletesiIdo = item.Field<DateTime>("TanarSzuletesiIdo");
|
||||
if (tanarDictionary.ContainsKey(tanarNev))
|
||||
{
|
||||
if (!tanarDictionary[tanarNev].Contains(tanarSzuletesiIdo))
|
||||
{
|
||||
tanarDictionary[tanarNev].Add(tanarSzuletesiIdo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tanarDictionary.Add(tanarNev, new List<DateTime> { tanarSzuletesiIdo });
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in ds.Tables[0].AsEnumerable())
|
||||
{
|
||||
if (SDAConvert.ToBoolean(item.Field<string>("IsOsztaly"), false))
|
||||
{
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Osztaly, item.Field<string>("OsztalyCsoport"));
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Csoport, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Csoport, item.Field<string>("OsztalyCsoport"));
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Osztaly, SDAConvert.ToBoolean(item.Field<string>("IsOsztalyBontottCsoport"), false) ? item.Field<string>("OsztalyBontottCsoportNev") : string.Empty);
|
||||
}
|
||||
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Tantargy, item.Field<string>("Tantargy"));
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Oraszam, item.Field<decimal>("Oraszam").ToString(), formatID: 4U);
|
||||
|
||||
//NOTE: Erre azért van szükség, ha több egyforma nevű tanár szerepel az adatbázisban, akkor zárójelben mögé tesszük a születési dátumát az export-ban, hogy meg tudjuk őket különböztetni!
|
||||
var tanarNev = item.Field<string>("Tanar");
|
||||
var tanarSzuletesiIdo = item.Field<DateTime>("TanarSzuletesiIdo");
|
||||
if (tanarDictionary[tanarNev].Count > 1)
|
||||
{
|
||||
var tanarSzuletesiIdoString = tanarSzuletesiIdo.ToString(Constants.ToStringPattern.HungarianDate);
|
||||
tanarNev += $" ({tanarSzuletesiIdoString})";
|
||||
}
|
||||
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Tanar, tanarNev);
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.Tuloraszam, item.Field<decimal>("TuloraSzam").ToString());
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.IsOsszevontOra, item.Field<string>("OsszevontOra").ToBool().GetDisplayName());
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.IsNemzetisegiOra, item.Field<string>("NemzetisegiOra").ToBool().GetDisplayName());
|
||||
exportFile.AddCell(rowIndex, (int)EgyszeruTtfExportColumns.MegbizasiOraszam, item.Field<decimal>("MegbizasiOraszam").ToString());
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
return manager.CreateExcelExport(new List<ExcelExportItem> { exportFile });
|
||||
}
|
||||
|
||||
public MemoryStream ExportLepedoTTF()
|
||||
{
|
||||
return ExportLepedoTTF(null, null, null, null, null, null, null, null, null, null, false, false, false);
|
||||
}
|
||||
|
||||
public MemoryStream ExportLepedoOsztalyTTF()
|
||||
{
|
||||
return ExportLepedoOsztalyTTF(null, null, null, null, null, null, null, null, null, null, false, false, false);
|
||||
}
|
||||
|
||||
public MemoryStream ExportLepedoTTF(int? tanarId, int? csoportId, int? tantargyId, int? targyKatId, int? foglalkozasTipusId,
|
||||
int? feladatKategoriaId, int? feladatellatasiHelyId, int? evfolyamId, double? oraszam, bool? isImportalt, bool osztalybontasokkal, bool kapcsolodoCsoportokkal, bool isFromSzervezet)
|
||||
{
|
||||
var manager = new ExcelExportManager();
|
||||
var exportFile = new ExcelExportItem();
|
||||
|
||||
var helper = new TantargyFelosztasHelper(ConnectionType);
|
||||
var thelper = new TanarHelper(ConnectionType);
|
||||
|
||||
var ds = helper.GetTTFToExport(tanarId, csoportId, tantargyId, targyKatId, foglalkozasTipusId, feladatKategoriaId, feladatellatasiHelyId, evfolyamId, oraszam, isImportalt, osztalybontasokkal, kapcsolodoCsoportokkal, isFromSzervezet);
|
||||
var grouped = ds.Tables[0].AsEnumerable().GroupBy(t => new
|
||||
{
|
||||
Osztaly = t.Field<string>("Osztaly"),
|
||||
Csoport = t.Field<string>("CsoportNev"),
|
||||
Tantargy = t.Field<string>("Tantargy"),
|
||||
});
|
||||
|
||||
//NOTE: Erre azért van szükség, ha több egyforma nevű tanár szerepel az adatbázisban, akkor zárójelben mögé tesszük a születési dátumát az export-ban, hogy meg tudjuk őket különböztetni!
|
||||
var tanarDictionary = new Dictionary<string, List<DateTime>>();
|
||||
foreach (var item in ds.Tables[0].AsEnumerable())
|
||||
{
|
||||
var tanarNev = item.Field<string>("Tanar");
|
||||
var tanarSzuletesiIdo = item.Field<DateTime>("TanarSzuletesiIdo");
|
||||
if (tanarDictionary.ContainsKey(tanarNev))
|
||||
{
|
||||
if (!tanarDictionary[tanarNev].Contains(tanarSzuletesiIdo))
|
||||
{
|
||||
tanarDictionary[tanarNev].Add(tanarSzuletesiIdo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tanarDictionary.Add(tanarNev, new List<DateTime> { tanarSzuletesiIdo });
|
||||
}
|
||||
}
|
||||
|
||||
var tanarExcelColumnsDictionary = new Dictionary<string, int>();
|
||||
var column = 4; // Alap default oszlopok száma, ez után jönnek a tanárok
|
||||
foreach (var item in ds.Tables[0].AsEnumerable())
|
||||
{
|
||||
//NOTE: Erre azért van szükség, ha több egyforma nevű tanár szerepel az adatbázisban, akkor zárójelben mögé tesszük a születési dátumát az export-ban, hogy meg tudjuk őket különböztetni!
|
||||
var tanarNev = item.Field<string>("Tanar");
|
||||
var tanarSzuletesiIdo = item.Field<DateTime>("TanarSzuletesiIdo");
|
||||
if (tanarDictionary[tanarNev].Count > 1)
|
||||
{
|
||||
var tanarSzuletesiIdoString = tanarSzuletesiIdo.ToString(Constants.ToStringPattern.HungarianDate);
|
||||
tanarNev += $" ({tanarSzuletesiIdoString})";
|
||||
}
|
||||
|
||||
if (!tanarExcelColumnsDictionary.ContainsKey(tanarNev))
|
||||
{
|
||||
tanarExcelColumnsDictionary.Add(tanarNev, column);
|
||||
column++;
|
||||
}
|
||||
}
|
||||
|
||||
//Kérésre a ttf-ben nem szereplő tanárokat is hozzá adjuk a listához
|
||||
var osszestanar = thelper.GetAlkalmazottNevek(false, isFromSzervezet);
|
||||
osszestanar.Remove(string.Empty);
|
||||
foreach (var tanar in osszestanar)
|
||||
{
|
||||
if (!tanarExcelColumnsDictionary.Keys.Contains(tanar.Value))
|
||||
{
|
||||
tanarExcelColumnsDictionary.Add(tanar.Value, column);
|
||||
column++;
|
||||
}
|
||||
}
|
||||
|
||||
PrePareTtfExportDocument(exportFile, tanarExcelColumnsDictionary, grouped.Count());
|
||||
var sor = 3;
|
||||
foreach (var item in grouped)
|
||||
{
|
||||
exportFile.AddCell(sor, (int)TtfExportColumns.Osztaly, item.Key.Osztaly);
|
||||
exportFile.AddCell(sor, (int)TtfExportColumns.Csoport, item.Key.Csoport);
|
||||
exportFile.AddCell(sor, (int)TtfExportColumns.Tantargy, item.Key.Tantargy);
|
||||
exportFile.AddCell(sor, (int)TtfExportColumns.Osszes, string.Empty, string.Format("SUM({0}{1}:{2}{1})", GetExcelColumnName((int)TtfExportColumns.Osszes + 2), sor, GetExcelColumnName((int)TtfExportColumns.Osszes + 1 + tanarExcelColumnsDictionary.Count)), formatID: 3U);
|
||||
foreach (var rowdata in item.ToList())
|
||||
{
|
||||
//NOTE: Erre azért van szükség, ha több egyforma nevű tanár szerepel az adatbázisban, akkor zárójelben mögé tesszük a születési dátumát az export-ban, hogy meg tudjuk őket különböztetni!
|
||||
var tanarNev = rowdata.Field<string>("Tanar");
|
||||
var tanarSzuletesiIdo = rowdata.Field<DateTime>("TanarSzuletesiIdo");
|
||||
if (tanarDictionary[tanarNev].Count > 1)
|
||||
{
|
||||
var tanarSzuletesiIdoString = tanarSzuletesiIdo.ToString(Constants.ToStringPattern.HungarianDate);
|
||||
tanarNev += $" ({tanarSzuletesiIdoString})";
|
||||
}
|
||||
|
||||
exportFile.AddCell(sor, tanarExcelColumnsDictionary[tanarNev], Convert.ToDecimal(rowdata["Oraszam"], CultureInfo.InvariantCulture), valuetype: DocumentFormat.OpenXml.Spreadsheet.CellValues.Number, formatID: 4U);
|
||||
}
|
||||
|
||||
sor++;
|
||||
}
|
||||
|
||||
return manager.CreateExcelExport(new List<ExcelExportItem> { exportFile });
|
||||
}
|
||||
|
||||
public MemoryStream ExportLepedoOsztalyTTF(int? tanarId, int? csoportId, int? tantargyId, int? targyKatId, int? foglalkozasTipusId, int? feladatKategoriaId, int? feladatellatasiHelyId, int? evfolyamId, double? oraszam, bool? isImportalt, bool osztalybontasokkal, bool kapcsolodoCsoportokkal, bool isFromSzervezet)
|
||||
{
|
||||
var manager = new ExcelExportManager();
|
||||
var exportFile = new ExcelExportItem();
|
||||
|
||||
var helper = new TantargyFelosztasHelper(ConnectionType);
|
||||
var thelper = new TanarHelper(ConnectionType);
|
||||
|
||||
var ds = helper.GetTTFToExport(tanarId, csoportId, tantargyId, targyKatId, foglalkozasTipusId, feladatKategoriaId, feladatellatasiHelyId, evfolyamId, oraszam, isImportalt, osztalybontasokkal, kapcsolodoCsoportokkal, isFromSzervezet);
|
||||
|
||||
var azonosNevuek = ds.Tables[0].AsEnumerable().Select(x => new
|
||||
{
|
||||
Tanar = x.Field<string>("Tanar"),
|
||||
SzuletesiIdo = x.Field<DateTime>("TanarSzuletesiIdo").ToString(Constants.ToStringPattern.HungarianDate),
|
||||
}).Distinct().GroupBy(t => t.Tanar).Select(group => new
|
||||
{
|
||||
Tanar = group.Key,
|
||||
Count = group.Count()
|
||||
}).Where(x => x.Count > 1).Select(x => x.Tanar).ToList();
|
||||
|
||||
var grouped = ds.Tables[0].AsEnumerable().GroupBy(t => new
|
||||
{
|
||||
Tanar = t.Field<string>("Tanar"),
|
||||
SzuletesiIdo = t.Field<DateTime>("TanarSzuletesiIdo").ToString(Constants.ToStringPattern.HungarianDate),
|
||||
Tantargy = t.Field<string>("Tantargy"),
|
||||
}).ToList();
|
||||
|
||||
var osszestanar = thelper.GetTanarNevSzuletesiDatumok(isFromSzervezet);
|
||||
foreach (var tanar in osszestanar)
|
||||
{
|
||||
if (!grouped.Any(a => a.Key.Tanar == tanar.Value.Tanar && a.Key.SzuletesiIdo == tanar.Value.SzuletesiDatum.ToString(Constants.ToStringPattern.HungarianDate)))
|
||||
{
|
||||
var tanarNincsTTFben = new[] { ds.Tables[0].NewRow() }.GroupBy(val => new { Tanar = tanar.Value.Tanar, SzuletesiIdo = tanar.Value.SzuletesiDatum.ToString(Constants.ToStringPattern.HungarianDate), Tantargy = "" }).First();
|
||||
grouped.Add(tanarNincsTTFben);
|
||||
}
|
||||
}
|
||||
|
||||
var osztalyCsoportExcelColumnsDictionary = new List<(string osztaly, string csoport, int columnIndex)>();
|
||||
var column = 3; // Alap default oszlopok száma, ez után jönnek az osztálycsoportok
|
||||
foreach (var item in ds.Tables[0].AsEnumerable())
|
||||
{
|
||||
var osztalyNev = item.Field<string>("Osztaly") ?? "";
|
||||
var csoportNev = item.Field<string>("CsoportNev") ?? "";
|
||||
if (string.IsNullOrWhiteSpace(osztalyNev) && string.IsNullOrWhiteSpace(csoportNev))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (osztalyCsoportExcelColumnsDictionary.SingleOrDefault(x => x.osztaly == osztalyNev && x.csoport == csoportNev) == default)
|
||||
{
|
||||
osztalyCsoportExcelColumnsDictionary.Add((osztalyNev, csoportNev, column));
|
||||
column++;
|
||||
}
|
||||
}
|
||||
|
||||
PrepareOsztalyTtfExportDocument(exportFile, osztalyCsoportExcelColumnsDictionary, grouped.Count);
|
||||
var sor = 4;
|
||||
var sumLastColumn = osztalyCsoportExcelColumnsDictionary.Count != 0 ? (int)TtfExportOsztalyokColumns.Osszes + 1 + osztalyCsoportExcelColumnsDictionary.Count : (int)TtfExportOsztalyokColumns.Osszes + 2;
|
||||
foreach (var item in grouped)
|
||||
{
|
||||
var szulDatum = azonosNevuek.Contains(item.Key.Tanar) ? $" ({item.Key.SzuletesiIdo})" : "";
|
||||
exportFile.AddCell(sor, (int)TtfExportOsztalyokColumns.Tanar, item.Key.Tanar + szulDatum);
|
||||
exportFile.AddCell(sor, (int)TtfExportOsztalyokColumns.Tantargy, item.Key.Tantargy);
|
||||
exportFile.AddCell(sor, (int)TtfExportOsztalyokColumns.Osszes, string.Empty, string.Format("SUM({0}{1}:{2}{1})", GetExcelColumnName((int)TtfExportOsztalyokColumns.Osszes + 2), sor, GetExcelColumnName(sumLastColumn)), formatID: 3U);
|
||||
foreach (var rowdata in item.ToList())
|
||||
{
|
||||
var osztalyNev = rowdata.Field<string>("Osztaly") ?? "";
|
||||
var csoportNev = rowdata.Field<string>("CsoportNev") ?? "";
|
||||
var key = (!string.IsNullOrWhiteSpace(osztalyNev) ? osztalyNev : "") + (!string.IsNullOrWhiteSpace(osztalyNev) && !string.IsNullOrWhiteSpace(csoportNev) ? " - " : "") + (!string.IsNullOrWhiteSpace(csoportNev) ? csoportNev : "");
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
exportFile.AddCell(sor, osztalyCsoportExcelColumnsDictionary.Single(x => x.osztaly == osztalyNev && x.csoport == csoportNev).columnIndex, SDAConvert.ToDecimal(rowdata["Oraszam"]), valuetype: DocumentFormat.OpenXml.Spreadsheet.CellValues.Number, formatID: 4U);
|
||||
}
|
||||
sor++;
|
||||
}
|
||||
|
||||
return manager.CreateExcelExport(new List<ExcelExportItem> { exportFile });
|
||||
}
|
||||
|
||||
#region Formázott TTF export
|
||||
|
||||
public MemoryStream ExportFormazottTtf(int formatMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
var helper = new TantargyFelosztasHelper(ConnectionType);
|
||||
using (var result = new MemoryStream())
|
||||
{
|
||||
var ds = helper.GetFormazottTTFExport(formatMode);
|
||||
|
||||
if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0 &&
|
||||
ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0 &&
|
||||
(ds.Tables[2] != null && ds.Tables[2].Rows.Count > 0 || ds.Tables[3] != null && ds.Tables[3].Rows.Count > 0))
|
||||
{
|
||||
var excelPackage = new ExcelPackage(result);
|
||||
ExcelWorksheet ws0 = excelPackage.Workbook.Worksheets.Add("TTF");
|
||||
ws0.Cells["A1"].LoadFromDataTable(ds.Tables[0], true);
|
||||
|
||||
ExcelWorksheet ws1 = excelPackage.Workbook.Worksheets.Add("TTFX");
|
||||
ws1.Cells["A1"].LoadFromDataTable(ds.Tables[1], true);
|
||||
|
||||
ExcelWorksheet ws2 = excelPackage.Workbook.Worksheets.Add("O");
|
||||
ws2.Cells["A1"].LoadFromDataTable(ds.Tables[2], true);
|
||||
|
||||
ExcelWorksheet ws3 = excelPackage.Workbook.Worksheets.Add("CS");
|
||||
ws3.Cells["A1"].LoadFromDataTable(ds.Tables[3], true);
|
||||
|
||||
return ConvertExcel(new MemoryStream(excelPackage.GetAsByteArray()));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Ezt ne használjátok, át kell írni!")]
|
||||
public static MemoryStream ConvertExcel(MemoryStream OriginalStream)
|
||||
{
|
||||
var excelPackage = new ExcelPackage(OriginalStream);
|
||||
|
||||
#region ColorSetup
|
||||
|
||||
Color colorKretaBlue = Color.FromArgb(33, 167, 202);
|
||||
|
||||
Color colorLightKretaBlue = Color.FromArgb(67, 215, 254);
|
||||
|
||||
Color colorDarkKretaBlue = Color.FromArgb(10, 102, 105);
|
||||
|
||||
Color colorKretaOrange = Color.FromArgb(224, 82, 48);
|
||||
|
||||
Color colorKretaOrange2 = Color.FromArgb(236, 134, 39);
|
||||
|
||||
Color colorKretaOrange3 = Color.FromArgb(247, 185, 28);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialization
|
||||
|
||||
ExcelWorksheet Result = excelPackage.Workbook.Worksheets[1];
|
||||
ExcelWorksheet TTF = excelPackage.Workbook.Worksheets[2];
|
||||
ExcelWorksheet Osztalyok = excelPackage.Workbook.Worksheets[3];
|
||||
ExcelWorksheet Csoportok = excelPackage.Workbook.Worksheets[4];
|
||||
|
||||
Dictionary<string, int> OsztalyokList = new Dictionary<string, int>();
|
||||
Dictionary<string, int> CsoportokList = new Dictionary<string, int>();
|
||||
Dictionary<int, string> TTFList = new Dictionary<int, string>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Osztály és csoportoszlopok elkészítése
|
||||
|
||||
bool IsOsztaly = true;
|
||||
bool IsCsoport = true;
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 2; i <= Osztalyok.Dimension.End.Row; i++)
|
||||
{
|
||||
Result.Cells[1, 6 + i].Value = Osztalyok.Cells[i, 1].Value;
|
||||
OsztalyokList.Add(Osztalyok.Cells[i, 1].Value.ToString(), 6 + i);
|
||||
}
|
||||
|
||||
Result.Cells[1, Result.Dimension.End.Column + 1].Value = "Összesen (osztályok)";
|
||||
}
|
||||
catch
|
||||
{
|
||||
IsOsztaly = false;
|
||||
}
|
||||
|
||||
int startcolumn = Result.Dimension.End.Column;
|
||||
try
|
||||
{
|
||||
for (int i = 2, j = 1; i <= Csoportok.Dimension.End.Row; i++)
|
||||
{
|
||||
if (Csoportok.Cells[i, 2].Value == null)
|
||||
{
|
||||
Result.Cells[1, startcolumn + j].Value = Csoportok.Cells[i, 1].Value;
|
||||
CsoportokList.Add(Csoportok.Cells[i, 1].Value.ToString(), startcolumn + j);
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
CsoportokList.Add(Csoportok.Cells[i, 1].Value.ToString(), OsztalyokList.Where(x => x.Key.ToString() == Csoportok.Cells[i, 2].Value.ToString()).Single().Value);
|
||||
}
|
||||
}
|
||||
|
||||
Result.Cells[1, Result.Dimension.End.Column + 1].Value = "Összesen (csoportok)";
|
||||
}
|
||||
catch
|
||||
{
|
||||
IsCsoport = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Óraszámok betétele
|
||||
|
||||
for (int i = 2; i <= Result.Dimension.End.Row; i++)
|
||||
{
|
||||
TTFList.Add(i, Result.Cells[i, 1].Value.ToString() + " - " + Result.Cells[i, 5].Value.ToString());
|
||||
}
|
||||
|
||||
for (int i = 2; i <= TTF.Dimension.End.Row; i++)
|
||||
{
|
||||
string ttfname = TTF.Cells[i, 1].Value.ToString() + " - " + TTF.Cells[i, 3].Value.ToString();
|
||||
string ocsname = TTF.Cells[i, 5].Value.ToString();
|
||||
int column = 0;
|
||||
int row = 0;
|
||||
|
||||
row = TTFList.First(x => x.Value.ToString() == ttfname).Key;
|
||||
column = (OsztalyokList.ContainsKey(ocsname)) ? OsztalyokList.Where(x => x.Key.ToString() == ocsname).Single().Value : CsoportokList.Where(x => x.Key.ToString() == ocsname).Single().Value;
|
||||
|
||||
if (Result.Cells[row, column].Value == null)
|
||||
{
|
||||
Result.Cells[row, column].Value = Convert.ToDouble(TTF.Cells[i, 4].Value);
|
||||
Result.Cells[row, column].Style.Numberformat.Format = "0.00";
|
||||
}
|
||||
else
|
||||
{
|
||||
Result.Cells[row, column].Value = (Convert.ToDouble(Result.Cells[row, column].Value) + Convert.ToDouble(TTF.Cells[i, 4].Value));
|
||||
Result.Cells[row, column].Style.Numberformat.Format = "0.00";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Segédtáblák törlése
|
||||
|
||||
excelPackage.Workbook.Worksheets.Delete(4);
|
||||
excelPackage.Workbook.Worksheets.Delete(3);
|
||||
excelPackage.Workbook.Worksheets.Delete(2);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize
|
||||
|
||||
int firstcolnumber = 0;
|
||||
int firstrownumber = 0;
|
||||
int lastcolnumber = 0;
|
||||
int lastrownumber = 0;
|
||||
int OsszesenI = 0;
|
||||
int OsszesenII = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Oszlopmanipuláció
|
||||
|
||||
Result.DeleteColumn(7);
|
||||
|
||||
for (int colnumber = Result.Dimension.Start.Column;
|
||||
colnumber <= Result.Dimension.End.Column;
|
||||
colnumber++)
|
||||
{
|
||||
#region Oszlopnevek
|
||||
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "TanarNeve")
|
||||
Result.Cells[1, colnumber].Value = TantargyfelosztasResource.XlsExportPedagogusNeve;
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "Munkakor")
|
||||
Result.Cells[1, colnumber].Value = TantargyfelosztasResource.XlsExportMunkakore;
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "PedagogusAdatok")
|
||||
{
|
||||
Result.Cells[1, colnumber].Value = TantargyfelosztasResource.XlsExportOrakedvezmenyreJogosito;
|
||||
Result.Cells[1, colnumber].Style.WrapText = true;
|
||||
}
|
||||
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "PedagogusMunkaideje")
|
||||
{
|
||||
Result.Cells[1, colnumber].Value = TantargyfelosztasResource.XlsExportPedagogusMunkaideje;
|
||||
Result.Cells[1, colnumber].Style.WrapText = true;
|
||||
}
|
||||
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "PedagogusOrakedvezmenye")
|
||||
{
|
||||
Result.Cells[1, colnumber].Value = TantargyfelosztasResource.XlsExportPedagogusOrakedvezmenye;
|
||||
Result.Cells[1, colnumber].Style.WrapText = true;
|
||||
}
|
||||
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "TantargyNev")
|
||||
Result.Cells[1, colnumber].Value = TantargyfelosztasResource.XlsExportTantargyEgyeb;
|
||||
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "Összesen (osztályok)")
|
||||
OsszesenI = colnumber;
|
||||
if (Result.Cells[1, colnumber].Value.ToString() == "Összesen (csoportok)")
|
||||
OsszesenII = colnumber;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Some Variables
|
||||
|
||||
firstcolnumber = Result.Dimension.Start.Column;
|
||||
firstrownumber = Result.Dimension.Start.Row;
|
||||
|
||||
lastcolnumber = Result.Dimension.End.Column;
|
||||
lastrownumber = Result.Dimension.End.Row;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Main Formatting
|
||||
|
||||
for (int colnumber = Result.Dimension.Start.Column;
|
||||
colnumber <= Result.Dimension.End.Column;
|
||||
colnumber++)
|
||||
{
|
||||
for (int rownumber = Result.Dimension.Start.Row;
|
||||
rownumber <= Result.Dimension.End.Row;
|
||||
rownumber++)
|
||||
{
|
||||
Result.Cells[rownumber, colnumber].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[rownumber, colnumber].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[rownumber, colnumber].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[rownumber, colnumber].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, colnumber].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, colnumber].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, colnumber].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
if (rownumber == 1)
|
||||
{
|
||||
Result.Cells[rownumber, colnumber].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, colnumber].Style.Fill.BackgroundColor.SetColor(colorKretaBlue);
|
||||
Result.Cells[rownumber, colnumber].Style.Font.Bold = true;
|
||||
Result.Cells[rownumber, colnumber].Style.Font.Color.SetColor(Color.White);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (colnumber > 6)
|
||||
Result.Cells[rownumber, colnumber].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
|
||||
if ((IsOsztaly && colnumber == OsszesenI) || (IsCsoport && colnumber == OsszesenII))
|
||||
{
|
||||
Result.Cells[rownumber, colnumber].Style.Fill.BackgroundColor.SetColor(colorLightKretaBlue);
|
||||
Result.Cells[rownumber, colnumber].Style.Font.Bold = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Összegzések
|
||||
|
||||
double allOsszesen1 = 0;
|
||||
double allOsszesen2 = 0;
|
||||
|
||||
OsszesenI += 2;
|
||||
OsszesenII += 2;
|
||||
|
||||
Result.InsertColumn(6, 1);
|
||||
Result.InsertColumn(8, 1);
|
||||
|
||||
for (int i = 2; i <= Result.Dimension.End.Row; i++)
|
||||
{
|
||||
double osszeg1 = 0;
|
||||
double osszeg2 = 0;
|
||||
|
||||
if (IsOsztaly)
|
||||
{
|
||||
for (int j = 9; j < OsszesenI; j++)
|
||||
{
|
||||
if (Result.Cells[i, j].Value != null)
|
||||
{
|
||||
osszeg1 += Convert.ToDouble(Result.Cells[i, j].Value);
|
||||
}
|
||||
}
|
||||
|
||||
Result.Cells[i, OsszesenI].Value = osszeg1;
|
||||
allOsszesen1 += osszeg1;
|
||||
}
|
||||
|
||||
if (IsCsoport)
|
||||
{
|
||||
for (int j = (IsOsztaly) ? OsszesenI + 1 : 9; j < OsszesenII; j++)
|
||||
{
|
||||
if (Result.Cells[i, j].Value != null)
|
||||
{
|
||||
osszeg2 += Convert.ToDouble(Result.Cells[i, j].Value);
|
||||
}
|
||||
}
|
||||
|
||||
Result.Cells[i, OsszesenII].Value = osszeg2;
|
||||
allOsszesen2 += osszeg2;
|
||||
|
||||
}
|
||||
|
||||
Result.Cells[i, 6].Value = (osszeg1 + osszeg2);
|
||||
}
|
||||
|
||||
Result.InsertRow(2, 1);
|
||||
Result.Cells[2, 1, 2, 5].Merge = true;
|
||||
Result.Cells[2, 1].Value = TantargyfelosztasResource.XlsExportOsszesPedagogus;
|
||||
|
||||
for (int i = 1; i <= Result.Dimension.End.Column; i++)
|
||||
{
|
||||
if (i > 7)
|
||||
{
|
||||
double osszeg = 0;
|
||||
for (int j = 3; j <= Result.Dimension.End.Row; j++)
|
||||
{
|
||||
if (Result.Cells[j, i].Value != null)
|
||||
{
|
||||
osszeg += Convert.ToDouble(Result.Cells[j, i].Value);
|
||||
}
|
||||
}
|
||||
|
||||
Result.Cells[2, i].Value = osszeg;
|
||||
}
|
||||
|
||||
Result.Cells[2, i].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[2, i].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[2, i].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[2, i].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[2, i].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[2, i].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[2, i].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[2, i].Style.Fill.BackgroundColor.SetColor(colorLightKretaBlue);
|
||||
Result.Cells[2, i].Style.Font.Bold = true;
|
||||
Result.Cells[2, i].Style.Font.Color.SetColor(Color.Black);
|
||||
}
|
||||
|
||||
#region Összegzőoszlop
|
||||
|
||||
Result.Cells[1, 6].Value = TantargyfelosztasResource.XlsExportOraterviOrakEsEgyeb;
|
||||
Result.Cells[1, 6].Style.WrapText = true;
|
||||
Result.Cells[1, 6].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[1, 6].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[1, 6].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[1, 6].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 6].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 6].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 6].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 6].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[1, 6].Style.Fill.BackgroundColor.SetColor(colorKretaBlue);
|
||||
Result.Cells[1, 6].Style.Font.Bold = true;
|
||||
Result.Cells[1, 6].Style.Font.Color.SetColor(Color.White);
|
||||
|
||||
Result.Cells[1, 8].Value = TantargyfelosztasResource.XlsExportOsszesOraszam;
|
||||
Result.Cells[1, 8].Style.WrapText = true;
|
||||
Result.Cells[1, 8].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[1, 8].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[1, 8].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[1, 8].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 8].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 8].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 8].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 8].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[1, 8].Style.Fill.BackgroundColor.SetColor(colorKretaBlue);
|
||||
Result.Cells[1, 8].Style.Font.Bold = true;
|
||||
Result.Cells[1, 8].Style.Font.Color.SetColor(Color.White);
|
||||
|
||||
for (int rownumber = 2;
|
||||
rownumber <= Result.Dimension.End.Row;
|
||||
rownumber++)
|
||||
{
|
||||
Result.Cells[rownumber, 6].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[rownumber, 6].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[rownumber, 6].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[rownumber, 6].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 6].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 6].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 6].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 6].Style.Fill.BackgroundColor.SetColor(colorLightKretaBlue);
|
||||
Result.Cells[rownumber, 6].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 6].Style.Font.Bold = true;
|
||||
Result.Cells[rownumber, 8].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[rownumber, 8].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[rownumber, 8].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[rownumber, 8].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 8].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 8].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 8].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[rownumber, 8].Style.Fill.BackgroundColor.SetColor(colorLightKretaBlue);
|
||||
Result.Cells[rownumber, 8].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 8].Style.Font.Bold = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Merge
|
||||
|
||||
int TanarokSzama = 0;
|
||||
string CopyValue = string.Empty;
|
||||
int CopyRowNumber = 0;
|
||||
double actOraszam = 0;
|
||||
for (int rownumber = Result.Dimension.End.Row;
|
||||
rownumber > 2;
|
||||
rownumber--)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(SDAConvert.ToString(Result.Cells[rownumber, 1].Value)))
|
||||
{
|
||||
if (Result.Cells[rownumber, 1].Value.ToString() == CopyValue)
|
||||
{
|
||||
actOraszam += Convert.ToDouble(Result.Cells[rownumber, 6].Value);
|
||||
Result.Cells[rownumber, 1, CopyRowNumber, 1].Merge = true;
|
||||
Result.Cells[rownumber, 1, CopyRowNumber, 1].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 1, CopyRowNumber, 1].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 1, CopyRowNumber, 1].Style.Font.Bold = true;
|
||||
Result.Cells[rownumber, 2, CopyRowNumber, 2].Merge = true;
|
||||
Result.Cells[rownumber, 2, CopyRowNumber, 2].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 2, CopyRowNumber, 2].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 3, CopyRowNumber, 3].Merge = true;
|
||||
Result.Cells[rownumber, 3, CopyRowNumber, 3].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 3, CopyRowNumber, 3].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 3, CopyRowNumber, 3].Style.WrapText = true;
|
||||
Result.Cells[rownumber, 4, CopyRowNumber, 4].Merge = true;
|
||||
Result.Cells[rownumber, 4, CopyRowNumber, 4].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 4, CopyRowNumber, 4].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 5].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 5].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 6, CopyRowNumber, 6].Merge = true;
|
||||
Result.Cells[rownumber, 6, CopyRowNumber, 6].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 6, CopyRowNumber, 6].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 6].Value = actOraszam;
|
||||
Result.Cells[rownumber, 7, CopyRowNumber, 7].Merge = true;
|
||||
Result.Cells[rownumber, 7, CopyRowNumber, 7].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 7, CopyRowNumber, 7].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 8, CopyRowNumber, 8].Merge = true;
|
||||
Result.Cells[rownumber, 8, CopyRowNumber, 8].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 8, CopyRowNumber, 8].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 8].Value = actOraszam + Convert.ToDouble(Result.Cells[rownumber, 7].Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
TanarokSzama++;
|
||||
CopyValue = Result.Cells[rownumber, 1].Value.ToString();
|
||||
CopyRowNumber = rownumber;
|
||||
actOraszam = Convert.ToDouble(Result.Cells[rownumber, 6].Value);
|
||||
Result.Cells[rownumber, 1].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 1].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 1].Style.Font.Bold = true;
|
||||
Result.Cells[rownumber, 2].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 2].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 3].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 3].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 3].Style.WrapText = true;
|
||||
Result.Cells[rownumber, 4].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 4].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 5].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 5].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
||||
Result.Cells[rownumber, 6].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 6].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 7].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 7].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 8].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
Result.Cells[rownumber, 8].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
Result.Cells[rownumber, 8].Value = actOraszam + Convert.ToDouble(Result.Cells[rownumber, 7].Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fejlécnevek
|
||||
|
||||
Result.InsertRow(1, 1);
|
||||
if (IsOsztaly)
|
||||
{
|
||||
Result.Cells[1, 9, 1, OsszesenI].Merge = true;
|
||||
Result.Cells[1, 9].Value = TantargyfelosztasResource.XlsExportOsztalyok;
|
||||
Result.Cells[1, 9].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[1, 9].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[1, 9].Style.Font.Bold = true;
|
||||
Result.Cells[1, 9].Style.Font.Size = 12;
|
||||
Result.Cells[1, 9].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[1, 9].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 9].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 9].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 9].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 9].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
}
|
||||
|
||||
if (IsCsoport)
|
||||
{
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9, 1, OsszesenII].Merge = true;
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Value = TantargyfelosztasResource.XlsExportCsoportok;
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Font.Bold = true;
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Font.Size = 12;
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, (IsOsztaly) ? OsszesenI + 1 : 9].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
}
|
||||
|
||||
Result.Cells[1, 1, 1, 7].Merge = true;
|
||||
Result.Cells[1, 1].Value = TantargyfelosztasResource.XlsExportTantargyfelosztas;
|
||||
Result.Cells[1, 1].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
|
||||
Result.Cells[1, 1].Style.Fill.BackgroundColor.SetColor(Color.White);
|
||||
Result.Cells[1, 1].Style.Font.Bold = true;
|
||||
Result.Cells[1, 1].Style.Font.Size = 20;
|
||||
Result.Cells[1, 1].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
|
||||
Result.Cells[1, 1].Style.Border.Top.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 1].Style.Border.Left.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 1].Style.Border.Right.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 1].Style.Border.Bottom.Color.SetColor(Color.Black);
|
||||
Result.Cells[1, 1].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
|
||||
Result.Cells[3, 1].Value = "Összesen " + TanarokSzama.ToString() + " pedagógus";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Width and Autofit
|
||||
|
||||
for (int colnumber = Result.Dimension.Start.Column;
|
||||
colnumber <= Result.Dimension.End.Column;
|
||||
colnumber++)
|
||||
{
|
||||
if (colnumber > 8)
|
||||
{
|
||||
Result.Cells[2, colnumber, 2, colnumber].Style.TextRotation = 90;
|
||||
Result.Column(colnumber).Width = 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
Result.Cells[2, colnumber, lastrownumber, colnumber].AutoFitColumns();
|
||||
}
|
||||
}
|
||||
|
||||
Result.Cells[2, 1, 2, 1].AutoFitColumns(30);
|
||||
Result.Cells[2, 2, 2, 2].AutoFitColumns(25);
|
||||
if (IsOsztaly)
|
||||
Result.Column(OsszesenI).Width = 10;
|
||||
|
||||
if (IsCsoport)
|
||||
{
|
||||
Result.Column(OsszesenII).Width = 10;
|
||||
Result.Column(OsszesenII + 1).Width = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
Result.Column(OsszesenI + 1).Width = 10;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
excelPackage.Save();
|
||||
excelPackage.Stream.Seek(0, SeekOrigin.Begin);
|
||||
return new MemoryStream(excelPackage.GetAsByteArray());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
int dividend = columnNumber;
|
||||
string columnName = string.Empty;
|
||||
|
||||
while (dividend > 0)
|
||||
{
|
||||
var modulo = (dividend - 1) % 26;
|
||||
columnName = Convert.ToChar(65 + modulo) + columnName;
|
||||
dividend = (int)((dividend - modulo) / 26);
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
|
||||
private void PrePareTtfExportDocument(ExcelExportItem exportFile, Dictionary<string, int> tanarok, int groupsCount)
|
||||
{
|
||||
exportFile.AddColumn((int)TtfExportColumns.Osztaly, string.Empty, 0U);
|
||||
exportFile.AddColumn((int)TtfExportColumns.Csoport, string.Empty, 0U);
|
||||
exportFile.AddColumn((int)TtfExportColumns.Tantargy, string.Empty, 0U);
|
||||
exportFile.AddColumn((int)TtfExportColumns.Osszes, string.Empty, 0U);
|
||||
|
||||
foreach (var item in tanarok.Keys)
|
||||
{
|
||||
exportFile.AddColumn(tanarok[item], item, 5U);
|
||||
}
|
||||
|
||||
exportFile.AddCell(2, (int)TtfExportColumns.Osztaly, ImportExportTantargyfelosztasResource.ImportHeaderNameOsztaly, formatID: 6U);
|
||||
exportFile.AddCell(2, (int)TtfExportColumns.Csoport, ImportExportTantargyfelosztasResource.ImportHeaderNameCsoport, formatID: 6U);
|
||||
exportFile.AddCell(2, (int)TtfExportColumns.Tantargy, ImportExportTantargyfelosztasResource.ImportHeaderNameTantargy, formatID: 6U);
|
||||
exportFile.AddCell(2, (int)TtfExportColumns.Osszes, ImportExportTantargyfelosztasResource.ImportHeaderNameOsszesen, formatID: 3U);
|
||||
|
||||
var sumLastRow = groupsCount != 0 ? 2 + groupsCount : 3;
|
||||
for (int j = 1; j <= tanarok.Count; j++)
|
||||
{
|
||||
exportFile.AddCell(2, (int)TtfExportColumns.Osszes + j, string.Empty, string.Format("SUM({0}{1}:{0}{2})", GetExcelColumnName((int)TtfExportColumns.Osszes + j + 1), 3, sumLastRow), formatID: 3U);
|
||||
}
|
||||
}
|
||||
|
||||
private void PrepareOsztalyTtfExportDocument(ExcelExportItem exportFile, List<(string osztaly, string csoport, int columnIndex)> keresztTablaOszlopok, int groupsCount)
|
||||
{
|
||||
exportFile.AddColumn((int)TtfExportOsztalyokColumns.Tanar, string.Empty, 0U);
|
||||
exportFile.AddColumn((int)TtfExportOsztalyokColumns.Tantargy, string.Empty, 0U);
|
||||
exportFile.AddColumn((int)TtfExportOsztalyokColumns.Osszes, ImportExportTantargyfelosztasResource.ImportHeaderNameOsztaly, formatId: 4U);
|
||||
exportFile.AddCell(2, (int)TtfExportOsztalyokColumns.Osszes, ImportExportTantargyfelosztasResource.ImportHeaderNameCsoport, formatID: 4U);
|
||||
exportFile.AddCell(3, (int)TtfExportOsztalyokColumns.Tanar, ImportExportTantargyfelosztasResource.ImportHeaderNameTanar, formatID: 6U);
|
||||
exportFile.AddCell(3, (int)TtfExportOsztalyokColumns.Tantargy, ImportExportTantargyfelosztasResource.ImportHeaderNameTantargy, formatID: 6U);
|
||||
exportFile.AddCell(3, (int)TtfExportOsztalyokColumns.Osszes, ImportExportTantargyfelosztasResource.ImportHeaderNameOsszesen, formatID: 3U);
|
||||
|
||||
for (int j = 1; j <= keresztTablaOszlopok.Count; j++)
|
||||
{
|
||||
var (osztaly, csoport, columnIndex) = keresztTablaOszlopok[j - 1];
|
||||
exportFile.AddColumn(columnIndex, osztaly, formatId: 5U);
|
||||
exportFile.AddCell(2, columnIndex, csoport, formatID: 5U);
|
||||
exportFile.AddCell(3, columnIndex, string.Empty, string.Format("SUM({0}{1}:{0}{2})", GetExcelColumnName(columnIndex + 1), 4, 3 + groupsCount), formatID: 3U);
|
||||
}
|
||||
}
|
||||
|
||||
public enum EgyszeruTtfExportColumns
|
||||
{
|
||||
Osztaly = 0,
|
||||
Csoport = 1,
|
||||
Tantargy = 2,
|
||||
Oraszam = 3,
|
||||
Tanar = 4,
|
||||
Tuloraszam = 5,
|
||||
IsOsszevontOra = 6,
|
||||
IsNemzetisegiOra = 7,
|
||||
MegbizasiOraszam = 8
|
||||
}
|
||||
|
||||
public enum TtfExportColumns
|
||||
{
|
||||
Osztaly = 0,
|
||||
Csoport = 1,
|
||||
Tantargy = 2,
|
||||
Osszes = 3,
|
||||
Tanar = 4
|
||||
}
|
||||
|
||||
public enum TtfExportOsztalyokColumns
|
||||
{
|
||||
Tanar = 0,
|
||||
Tantargy = 1,
|
||||
Osszes = 2,
|
||||
OsztalyCsoport = 3,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue