/// <summary> /// 导出简历 /// </summary> /// <returns></returns> public ActionResult ExportWord(int id) { try { //获取数据 PersonalShowModel model = dal.GetPersonalModel(Convert.ToInt32(id)); //获取模板 string templateFile = Server.MapPath("~/Text1.dot"); string saveDocFile = Server.MapPath("~/Text1.docx"); //载入模板 Document doc = new Document(templateFile); //载入数据 String[] fieldNames = new String[] { "PersonName", "Sex", "Age", "Education", "Job", "Remark", "WorkLife", "ProjectLife", "EducationLife", "WorkDay", "Books", "InSchoolLife", "Language", "ProjectPower", "Honor", "TrainLife", "Hobby", "JobWanted" }; Object[] fieldValues = new Object[] { model.PersonName, model.Sex, model.PersonalInfoId, model.Education, model.Publications, model.Remark, model.Resume, "略", model.Educations, model.OutsourcingCompanyId + "年", "帝都本科 软件工程专业 4年", "多姿多彩美好生活", "英语 汉语", "悦动圈项目", "计算机操作语言之父", "火星时代培训机构", "打篮球,网游", "期望薪资" }; //合并模版,相当于页面的渲染 doc.MailMerge.Execute(fieldNames, fieldValues); //保存合并后的文档 doc.Save(saveDocFile); //保存导出 var docStream = new MemoryStream(); //导出数据 doc.Save(docStream, SaveOptions.CreateSaveOptions(SaveFormat.Doc)); return(base.File(docStream.ToArray(), "application/msword", "Template.doc")); } catch (Exception ex) { ViewBag.msg = ex.Message; } return(View("/RecruitHome/Recruit/PersonalInfo")); }
// GET: Recruit/RecruitHome public ActionResult PersonalInfo(string id, string loginid) { PersonalShowModel model = dal.GetPersonalModel(Convert.ToInt32(id)); ViewBag.LoginID = loginid; return(View(model)); }
/// <summary> /// 打印简历 /// </summary> /// <returns></returns> public ActionResult PrintWord(int id) { try { PersonalShowModel model = dal.GetPersonalModel(Convert.ToInt32(id)); string templateFile = Server.MapPath("~/Text1.dot"); string saveDocFile = Server.MapPath("~/Text1.docx"); //载入模板 Document doc = new Document(templateFile); //载入数据 String[] fieldNames = new String[] { "PersonName", "Sex", "Age", "Education", "Job", "Remark", "WorkLife", "ProjectLife", "EducationLife", "WorkDay", "Books", "InSchoolLife", "Language", "ProjectPower", "Honor", "TrainLife", "Hobby", "JobWanted" }; Object[] fieldValues = new Object[] { model.PersonName, model.Sex, model.PersonalInfoId, model.Education, model.Publications, model.Remark, model.Resume, "略", model.Educations, model.OutsourcingCompanyId + "年", "帝都本科 软件工程专业 4年", "多姿多彩美好生活", "英语 汉语", "悦动圈项目", "计算机操作语言之父", "火星时代培训机构", "打篮球,网游", "期望薪资" }; //合并模版,相当于页面的渲染 doc.MailMerge.Execute(fieldNames, fieldValues); doc.Print(); } catch (Exception) { throw; } return(View("/RecruitHome/Recruit/PersonalInfo")); }
public PersonalShowModel GetPersonalModel(int id) { PersonalShowModel model = new PersonalShowModel(); try { using (var dbcontext = new DB()) { var result = dbcontext.PersonalInfo.FirstOrDefault(m => m.PersonalInfoId == id); if (result != null) { model.PersonalInfoId = result.PersonalInfoId; model.OutsourcingCompanyId = result.OutsourcingCompanyId; model.PersonName = result.PersonName; model.Remark = result.Remark; model.Resume = result.Resume; model.Educations = result.Attachment; model.Sex = result.Sex; model.Birthday = result.Birthday; model.Education = result.Education; model.Email = result.Email; model.Telphone = result.Telephone; model.GraduationSchool = result.GraduationSchool; model.GraduationDate = result.GraduationDate; model.Publications = result.Publications; model.CreateTime = result.CreateTime; model.UpdateTime = result.UpdateTime; if (!string.IsNullOrWhiteSpace(model.OutsourcingCompanyId)) { int companyID = Convert.ToInt32(model.OutsourcingCompanyId); var resultModle = dbcontext.OutsourcingCompany.FirstOrDefault(m => m.CompnayId == companyID); if (resultModle != null) { model.CompnayName = resultModle.CompnayName; model.EnglishName = resultModle.EnglishName; model.LegalRepresentative = resultModle.LegalRepresentative; model.LegalTelephone = resultModle.LegalTelephone; model.UnitResponsible = resultModle.UnitResponsible; model.ResponsibleTelephone = resultModle.ResponsibleTelephone; model.Address = resultModle.Address; model.EnterpriseNum = resultModle.EnterpriseNum; model.Descriptions = resultModle.Descriptions; model.Nature = resultModle.Nature; model.BusinessScope = resultModle.BusinessScope; } } } } return(model); } catch (Exception) { throw; } }