public ActionResult Create(ApplyProject applyproject, HttpPostedFileBase AttachFile = null)
        {
            String FileUrl;

            if (ModelState.IsValid)
            {
                if (AttachFile != null)
                {
                    AttachFile = Request.Files["AttachFile"];
                    if (AttachFile.ContentLength > 0)
                    {
                        FileUrl = "upload/";
                        String Path = Server.MapPath("~/") + FileUrl;
                        String FileName = DateTime.UtcNow.ToString("yyyy" + "MM" + "dd" + "HH" + "mm" + "ss" + "ffffff");
                        FileUrl = FileUrl + FileName;
                        if (!Directory.Exists(Path))
                            Directory.CreateDirectory(Path);
                        String extstr = System.IO.Path.GetExtension(AttachFile.FileName);
                        AttachFile.SaveAs(Path + FileName + extstr);
                        applyproject.ProjectAttach = FileUrl + extstr;
                    }
                }
                else
                {
                    applyproject.ProjectAttach = "";
                }
                applyproject.ApplyPeopleDepartment = "实验中心";
                applyproject.ApplyPeopleName = "王凯斯";
                UsersContext xx = new UsersContext();
                db.ApplyProjectSet.Add(applyproject);
                db.SaveChanges();
                string phyPath = HttpContext.Request.MapPath("/");
                OfficeController oc = new OfficeController();
                oc.BuildWord(applyproject, phyPath);
                return RedirectToAction("Index");
            }

            return View(applyproject);
        }
        public ActionResult Edit(ApplyProject applyproject, HttpPostedFileBase AttachFile = null)
        {
            String FileUrl;
            if (ModelState.IsValid)
            {
                if (AttachFile != null)
                {
                    AttachFile = Request.Files["AttachFile"];
                    if (AttachFile.ContentLength > 0)
                    {
                        FileUrl = "upload/";
                        String Path = Server.MapPath("~/") + FileUrl;
                        String FileName = DateTime.UtcNow.ToString("yyyy" + "MM" + "dd" + "HH" + "mm" + "ss" + "ffffff");
                        FileUrl = FileUrl + FileName;
                        if (!Directory.Exists(Path))
                            Directory.CreateDirectory(Path);
                        String extstr = System.IO.Path.GetExtension(AttachFile.FileName);
                        AttachFile.SaveAs(Path + FileName + extstr);
                        applyproject.ProjectAttach = FileUrl + extstr;

                    }
                }

                applyproject.ApplyPeopleDepartment = "实验中心";
                applyproject.ApplyPeopleName = "王凯斯";
                db.Entry(applyproject).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(applyproject);
        }
        public String BuildWord(ApplyProject applyproject, String phyPath)
        {
            object filename = phyPath + "test.doc";
            //创建Word文档
            Object Nothing = System.Reflection.Missing.Value;
            object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;

            Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            //添加页眉
            WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
            WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
            WordApp.ActiveWindow.ActivePane.Selection.InsertAfter("[页眉内容]");
            WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;//设置右对齐
            WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;//跳出页眉设置
            WordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距
            AddContent(WordDoc, "附件二:", 15, "黑体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 0);
            AddContent(WordDoc, "", 17, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 0);

            AddContent(WordDoc, "", 17, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 0);
            AddContent(WordDoc, "", 17, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 0);
            AddContent(WordDoc, "贵州民族大学基本建设投资项目", 18, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 1);
            AddContent(WordDoc, "", 17, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 0);
            insertline(1, WordDoc);
            AddContent(WordDoc, "申请书", 18, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 1);
            AddContent(WordDoc, "", 14, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 0);
            insertline(6, WordDoc);
            AddContent(WordDoc, "项  目  名   称:_____________________", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 1);
            AddContent(WordDoc, "申  请  学   校:贵州民族学院 (公章)", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 1);
            AddContent(WordDoc, "项 目  负 责 人:             (签名)", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 1);
            AddContent(WordDoc, "申  报  日   期:       年   月    日", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 1);
            insertline(6, WordDoc);
            AddContent(WordDoc, "贵州民族学院发展规划处制", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter, 1);
            WordDoc.Paragraphs.Last.Range.InsertBreak(ref oPageBreak);//插入了一页
            AddContent(WordDoc, "一、项目概况", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "1、项目名称:" + applyproject.ProjectNameTitle, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "2、项目类型:" + applyproject.ProjectType, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "3、项目负责人基本情况:" + applyproject.ProjectLeaderDetail, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "4、项目简介:" + applyproject.ProjectAbstract, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "二、项目建设的意义和可行性", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, applyproject.ProjectMeaning, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "三、项目建设目标", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "1、建设目标" + applyproject.BulidTarget, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "2、建设内容" + applyproject.BulidContent, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "四、项目建设任务", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, applyproject.BulidTask, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "五、项目预期成效", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, applyproject.ExpectEffect, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "六、建设项目实施组织及进度安排", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, applyproject.ProjectSchedule, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "七、保障措施", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, applyproject.ProjectEnsure, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, "八、项目支出预算及安排(附设备采购清单)", 16, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);
            AddContent(WordDoc, applyproject.ProjectPay, 12, "宋体", Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft, 1);

            // myRange.Font.Size = 24;
            object FileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument97;
            //文件保存
            WordDoc.SaveAs(ref filename, ref FileFormat, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
            WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);

            return "sucess";
        }