Ejemplo n.º 1
0
        public void AddRedTitle(Missive model, MissiveRedTitle redTitle)
        {
            if (redTitle.TemplateId == 0 || redTitle.Template == null)
            {
                return;
            }
            if (model.ContentId > 0 && model.Content == null)
            {
                model.Content = Core.FileManager.GetModel(model.ContentId);
            }
            var fileDoc     = WordHelper.CreateDoc(model.Content.PhysicalPath);
            var redTitleDoc = WordHelper.CreateDoc(redTitle.Template.PhysicalPath);
            var doc         = new XWPFDocument(redTitleDoc.Package);

            doc.CopyElements(fileDoc);
            doc.ReplaceContent("{文件字号}", model.WJ_ZH);
            doc.SaveAs(model.Content.AbsolutelyPath);
        }
Ejemplo n.º 2
0
        public Stream ExportTrend(int year, Quarter quarter, int[] formIds)
        {
            var doc = WordHelper.CreateDoc("templates/资源形势模板.docx");

            doc.WriteTitle(year + "年" + quarter.GetDescription() + "国土资源主要指标走势", "2");
            foreach (var form in Core.FormManager.GetForms(formIds))
            {
                var parameter = new NodeValueParameter
                {
                    FormID       = form.ID,
                    Year         = year,
                    Quarter      = quarter,
                    GetNode      = false,
                    GetArea      = false,
                    GetValueType = true,
                    RateType     = RateType.YearOnYear,
                };
                var values = Core.FormManager.GetNodeValues(parameter);
                var nodes  = Core.FormManager.GetRootNodes(form.ID);
                doc.WriteTitle(form.Name, "3", NPOI.XWPF.UserModel.ParagraphAlignment.LEFT);
                var sb = new StringBuilder();
                foreach (var node in nodes)
                {
                    var nodeContent = GenerateContent(node, values);
                    if (nodeContent.Length > 0)
                    {
                        sb.Append(nodeContent.Trim(';').Replace(",,", ",") + "。");
                    }
                }


                doc.WriteContent(sb.ToString());
            }

            return(doc.GetStream());
        }