예제 #1
0
        public async Task <string> GenerateExcelReport(int cultureId)
        {
            var translations = await _translationService.GetTranslationsForCulture(cultureId);

            var cultureInfo = await _cultureService.GetCultureInfo(cultureId);

            var            excelPackage = new ExcelPackage();
            ExcelWorksheet sheet        = excelPackage.Workbook.Worksheets.Add(cultureInfo.CultureName);

            //setting headers
            var cell = sheet.Cells[1, 1];

            cell.Value           = "Translation key";
            cell.Style.Font.Bold = true;
            cell                 = sheet.Cells[1, 2];
            cell.Value           = "Translation value";
            cell.Style.Font.Bold = true;

            //setting translation pairs
            var rowId = 2;

            foreach (var translation in translations)
            {
                cell       = sheet.Cells[rowId, 1];
                cell.Value = translation.Key;
                cell       = sheet.Cells[rowId, 2];
                cell.Value = translation.Value;
                rowId++;
            }

            sheet.Protection.IsProtected            = false;
            sheet.Protection.AllowSelectLockedCells = false;

            string fileName, path;

            fileName = GetFileName(cultureInfo.DisplayName, ".xlsx");
            path     = Path.Combine(_templatePath, fileName);

            var fileInfo = new FileInfo(path);

            excelPackage.SaveAs(fileInfo);
            return(fileName);
        }
예제 #2
0
        public async Task <List <TranslationVO> > Get(int id)
        {
            var result = await _translationService.GetTranslationsForCulture(id);

            return(result);
        }