示例#1
0
        static public void Export(string file, string lang)
        {
            fileName = file;
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;

            using (var excel = new ExcelPackage(new FileInfo(file)))
            {
                ExcelWorksheet worksheet = excel.Workbook.Worksheets["Sheet1"];
                XLS            diagXls   = new XLS();
                XLS            strXls    = new XLS();
                var            diagQty   = 0;
                var            strQty    = 0;
                for (int i = 1; i < worksheet.Dimension.Rows + 1; i++)
                {
                    for (int j = 1; j < worksheet.Dimension.Columns + 1; j++)
                    {
                        if (worksheet.Cells[i, j].Value != null)
                        {
                            string value = worksheet.Cells[i, j].Value.ToString();
                            switch (value)
                            {
                            case "dialog":
                                if (worksheet.Cells[i + 1, j].Value != null)
                                {
                                    diagXls.Entries.Add(new XLS.Entry
                                    {
                                        ID     = (uint)diagQty,
                                        Row    = (uint)i,
                                        Column = (uint)j,
                                        Text   = worksheet.Cells[i + 1, j].Value.ToString(),
                                    });
                                    diagQty++;
                                }
                                break;

                            case "string":
                                if (worksheet.Cells[i + 1, j].Value != null)
                                {
                                    strXls.Entries.Add(new XLS.Entry
                                    {
                                        ID     = (uint)strQty,
                                        Row    = (uint)i,
                                        Column = (uint)j,
                                        Text   = worksheet.Cells[i + 1, j].Value.ToString(),
                                    });
                                    strQty++;
                                }
                                break;
                            }
                        }
                    }
                }
                GeneratePo(diagXls, lang, true);
                GeneratePo(strXls, lang, false);
            }
        }
示例#2
0
        public IActionResult MakeRiskTable()
        {
            XLS    xls  = Utils.GetObjectFromJsonInRequest <XLS>(Request);
            string path = Path.Combine(Environment.CurrentDirectory, (xls.Name + "_Risk.xls"));

            if (System.IO.File.Exists(path))
            {
                System.IO.File.Delete(path);
            }
            System.IO.File.WriteAllText(path, xls.tableHTML);
            return(Ok());
        }
示例#3
0
        static private void GeneratePo(XLS xls, string lang, bool mode)
        {
            var po = new Po
            {
                Header = new PoHeader("Trails in the Cold Steel", "*****@*****.**", lang)
                {
                    LanguageTeam = lang,
                }
            };

            foreach (var entry in xls.Entries)
            {
                if (!string.IsNullOrEmpty(entry.Text))
                {
                    po.Add(new PoEntry(entry.Text)
                    {
                        Context           = entry.ID.ToString(),
                        ExtractedComments = $"{entry.Column}{";"}{entry.Row + 1}",
                    });
                }
            }

            var node = NodeFactory.FromMemory("node");

            switch (mode)
            {
            case true:
                node.TransformWith(new Po2BinaryEasy()
                {
                    PoPassed = po
                }).TransformWith(new Po2Binary()).Stream.WriteTo(Path.GetFileNameWithoutExtension(fileName) + "_dialog.po");
                break;

            case false:
                node.TransformWith(new Po2BinaryEasy()
                {
                    PoPassed = po
                }).TransformWith(new Po2Binary()).Stream.WriteTo(Path.GetFileNameWithoutExtension(fileName) + "_string.po");
                break;
            }
        }