//用于提供下载支持 protected void Page_Load(object sender, EventArgs e) { string flow = B_Route.GetParam("Flow", this); string file = B_Route.GetParam("File", this); SafeSC.DownFile("/WebFont/Users/" + flow + "/" + file); }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { string pdir = function.VToP(CurDirPath); string ppath = pdir + e.CommandArgument.ToString(); string fname = Path.GetFileNameWithoutExtension(e.CommandArgument.ToString()); string ext = Path.GetExtension(e.CommandArgument.ToString()); if (e.CommandName == "DelFiles") { FileSystemObject.Delete(ppath, FsoMethod.File); Response.Redirect(Request.RawUrl); } if (e.CommandName == "DelDir") { FileSystemObject.Delete(ppath, FsoMethod.Folder); Response.Redirect(Request.RawUrl); } if (e.CommandName == "CopyDir") { FileSystemObject.CopyDirectory(ppath, pdir + fname + "_" + Resources.L.制 + ext); //"复制_" + ppath Response.Redirect(Request.RawUrl); } if (e.CommandName == "CopyFiles") { FileSystemObject.CopyFile(ppath, pdir + fname + "_" + Resources.L.制 + ext); Response.Redirect(Request.RawUrl); } if (e.CommandName == "DownFiles") { SafeSC.DownFile(CurDirPath + e.CommandArgument.ToString(), e.CommandArgument.ToString()); } }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Del") { string LabelName = e.CommandArgument.ToString(); bll.DelLabelXML(LabelName); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Copy") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); newlbl.LableName = newlbl.LableName + DataSecurity.RandomNum(4); newlbl.LabelID = 0; bll.AddLabelXML(newlbl); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Download") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); XmlDocument doc = new XmlDocument(); XmlNode nodelist = doc.SelectSingleNode("//NewDataSet/Table[LabelID='" + newlbl.LabelID.ToString() + "']"); string fileName = newlbl.LableName + ".lable";//客户端保存的文件名 string path = newlbl.LabelCate + "/" + newlbl.LableName + ".label"; SafeSC.DownFile(bll.dir + path, HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); } }
protected void EGV_RowCommand(object sender, GridViewCommandEventArgs e) { string fname = e.CommandArgument.ToString(); string logpath = GetLogPath() + fname; switch (e.CommandName) { case "view": viewdiv.Visible = true; egvdiv.Visible = false; Curfname_Hid.Value = fname; string text = SafeSC.ReadFileStr(logpath); if (text.Trim().Length < 30) { text = "该日志无记录"; } LogTxt_Li.Text = text.Replace("\r\n", "<br />"); //替换文本换行 break; case "down": SafeSC.DownFile(logpath); break; case "del2": SafeSC.DelFile(logpath); MyBind(); break; } }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { string fname = Path.GetFileNameWithoutExtension(e.CommandArgument.ToString()); string ext = Path.GetExtension(e.CommandArgument.ToString()); if (e.CommandName == "DelFiles") { FileSystemObject.Delete(PPathDir + e.CommandArgument.ToString(), FsoMethod.File); } if (e.CommandName == "DelDir") { FileSystemObject.Delete(PPathDir + e.CommandArgument.ToString(), FsoMethod.Folder); } if (e.CommandName == "CopyFiles") { FileSystemObject.CopyFile(PPathDir + e.CommandArgument.ToString(), PPathDir + fname + "_复制" + ext); } if (e.CommandName == "CopyDir") { FileSystemObject.CopyDirectory(PPathDir + e.CommandArgument.ToString(), PPathDir + fname + "_复制" + ext); } if (e.CommandName == "DownFiles") { string filePath = function.PToV(PPathDir) + e.CommandArgument.ToString(); SafeSC.DownFile(filePath, HttpUtility.UrlEncode(e.CommandArgument.ToString(), System.Text.Encoding.UTF8)); } Response.Redirect(Request.RawUrl); }
protected void DownLog_Btn_Click(object sender, EventArgs e) { string fname = Curfname_Hid.Value; string logpath = GetLogPath() + fname; SafeSC.DownFile(logpath); }
protected void DownSite_Btn_Click(object sender, EventArgs e) { DataTableHelper dtHelper = new DataTableHelper(); M_Design_SiteInfo sfMod = sfBll.SelReturnModel(SiteID); M_UserInfo mu = buser.GetLogin(); ZipClass zip = new ZipClass(); //------------------------------ //整合节点与内容,站点信息,生成XML文件 string xmlDir = function.VToP(sfMod.SiteDir + "Init/"); DataSet ds = desHelper.PackSiteToDS(sfMod.ID); if (!Directory.Exists(xmlDir)) { Directory.CreateDirectory(xmlDir); } ds.WriteXml(xmlDir + "Site.xml"); //页面信息单独存 DataTable dt = pageBll.U_Sel(mu.UserID, sfMod.ID, M_Design_Page.PageEnum.All); dt.DataSet.WriteXml(xmlDir + "Page.xml"); //模板与资源打包 string zipDir = function.VToP("/Temp/SiteDown/"); string zipPath = zipDir + sfMod.ID + ".zip"; if (!Directory.Exists(zipDir)) { Directory.CreateDirectory(zipDir); } zip.Zip(function.VToP(sfMod.SiteDir), zipPath); SafeSC.DownFile(function.PToV(zipPath), sfMod.SiteName + ".zip");//打包成为tlp? }
protected void EGV_RowCommand(object sender, GridViewCommandEventArgs e) { M_UserInfo mu = buser.GetLogin(); switch (e.CommandName) { case "capp": M_App appMod = new M_App(); appMod.APKMode = 2; appMod.AppName = "temp"; appMod.MyStatus = 0; appMod.UserID = mu.UserID.ToString(); break; case "down": { int id = Convert.ToInt32(e.CommandArgument); M_APP_APPTlp tlpMod = tlpBll.SelReturnModel(id); if (tlpMod.UserID != mu.UserID) { function.WriteErrMsg("你没有下载该模板的权限"); } SafeSC.DownFile(tlpMod.TlpUrl); } break; } }
public ActionResult FiServerInfo() { string Menu = Request.QueryString["menu"] ?? ""; string Path = Request.QueryString["filepath"]; if (Menu.Equals("filedown") && !string.IsNullOrEmpty(Path)) { FileInfo file = new FileInfo(function.VToP(Path)); if (file.Exists) { SafeSC.DownFile(Path); } else { function.WriteErrMsg("文件不存在"); return(null); } } M_IServer serverMod = isBll.SelReturnModel(Mid); if (serverMod == null) { function.WriteErrMsg("问题不存在"); return(null); } //回复列表 ViewBag.replydt = repBll.SeachById(serverMod.QuestionId); //更新已读状态 repBll.GetUpdataState(1, serverMod.QuestionId); return(View(serverMod)); }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "DownFiles") { SafeSC.DownFile(BaseDir + e.CommandArgument.ToString()); } }
protected void DownWord_B_Click(object sender, EventArgs e) { StringWriter sw = new StringWriter(); var mu = buser.GetLogin(); string url = "ExportIDCOrder.aspx?id=" + Mid + "&uname=" + mu.UserName + "&upwd=" + mu.UserPwd; string vpath = "/UploadFiles/IDC订单详情-" + Mid + ".doc"; Server.Execute(url, sw); SafeSC.DownFile(OfficeHelper.W_HtmlToWord(sw.ToString(), vpath)); }
public void Tlp_Down(int id) { M_APP_APPTlp tlpMod = tlpBll.SelReturnModel(id); if (tlpMod.UserID != buser.GetLogin().UserID) { function.WriteErrMsg("你没有下载该模板的权限"); } SafeSC.DownFile(tlpMod.TlpUrl); }
protected void DownDoc_Btn_Click(object sender, EventArgs e) { M_Plat_Comp compMod = compBll.SelReturnModel(Mid); string html = Request.Form["html_hid"]; html = "<html><head></head><body>" + html + "</body></html>"; string vpath = "/UploadFiles/Plat/CompReport/" + compMod.CompName + ".doc"; vpath = OfficeHelper.W_HtmlToWord(html, vpath); SafeSC.DownFile(vpath); }
protected void RShowFilelist_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Down": SafeSC.DownFile(e.CommandArgument.ToString()); break; default: break; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string wordName = HttpUtility.UrlDecode(Request["Name"] ?? ""); string wordDir = "/UploadFiles/auto/outToWord/"; if (string.IsNullOrEmpty(wordName)) { wordName = function.GetRandomString(6); } SafeSC.CreateDir(wordDir); string wordPath = wordDir + wordName + ".docx"; SafeSC.DownFile(OfficeHelper.W_HtmlToWord("<html>" + Html + "</html>", wordPath)); } }
//Compress protected void ZipSite_Click(object sender, EventArgs e) { ZipClass ZC = new ZipClass(); string ppath = iis.Sites[siteName].Applications[0].VirtualDirectories[index].PhysicalPath; string temp = Server.MapPath(SiteConfig.SiteOption.UploadDir + "Site/"); if (!Directory.Exists(temp)) { Directory.CreateDirectory(temp); } temp += siteName + ".zip"; if (ZC.Zip(ppath, temp)) { SafeSC.DownFile(function.PToV(temp), HttpUtility.UrlEncode(siteName + ".zip", System.Text.Encoding.UTF8)); } }
public void MyBind() { NodeDPBind(); if (!string.IsNullOrEmpty(Url))//普通页面,新浪等 { string html = htmlHelper.GetHtmlFromSite(Url); Content_T.Text = acBll.GetArticleFromWeb(html, Url); Title_T.Text = Request["Title"] == null?htmlHelper.GetTitle(html) : Request["Title"]; SourceUrl_T.Text = Request["Source"] == null?GetSource(Url) : Request["Source"]; Author_T.Text = Request["Author"] == null?badmin.GetAdminLogin().AdminName : Request["Author"]; Synopsis_T.Text = DateTime.Now.ToString(); } else if (!string.IsNullOrEmpty(Request.Form["cms_json_hid"]))//页面下载,视频下载等 { JObject json = (JObject)JsonConvert.DeserializeObject(Request.Form["cms_json_hid"]); switch (json["action"].ToString()) { case "downpage": if (json["url"] == null || string.IsNullOrEmpty(json["url"].ToString())) { return; } string title = json["title"].ToString(); title = string.IsNullOrEmpty(title) ? "无标题.mht" : SafeC.RemovePathChar(title + ".mht"); string vpath = "/Temp/DownPage/" + title; if (!Directory.Exists(Server.MapPath("/Temp/DownPage/"))) { Directory.CreateDirectory(Server.MapPath("/Temp/DownPage/")); } vpath = htmlHelper.DownToMHT(json["url"].ToString(), vpath); SafeSC.DownFile(vpath); SafeSC.DelFile(vpath); Response.End(); break; case "video": Title_T.Text = json["title"].ToString(); SourceUrl_T.Text = GetSource(json["url"].ToString()); Content_T.Text = json["content"].ToString(); break; } } }
public void APPList_Down() { M_UserInfo mu = buser.GetLogin(); M_App appMod = appBll.Select(DataConverter.CLng(Request["ID"])); if (!mu.UserID.ToString().Equals(appMod.UserID)) { function.WriteErrMsg("你无权下载该APK"); return; } string fpath = appMod.APPDir + "\\" + appMod.AppName + ".apk"; if (!System.IO.File.Exists(fpath)) { function.WriteErrMsg("文件不存在"); } SafeSC.DownFile(function.PToV(fpath)); }
public void DownImg() { string base64 = Request.Form["img_hid"]; if (string.IsNullOrEmpty(base64)) { Response.Write("数据为空,无法生成图片"); Response.End(); return; } if (base64.Contains(",")) { base64 = base64.Split(',')[1]; } ImgHelper imgHelper = new ImgHelper(); string vpath = "/UploadFiles/dai/" + function.GetRandomString(6) + ".jpg"; imgHelper.Base64ToImg(vpath, base64); SafeSC.DownFile(vpath, "glassed.jpg"); }
protected void Page_Load(object sender, EventArgs e) { B_Admin b_Admin = new B_Admin(); if (string.IsNullOrEmpty(Request.QueryString["QuestionId"])) { function.WriteErrMsg("不存在"); } int QuestionId = int.Parse(Request.QueryString["QuestionId"]); if (!string.IsNullOrEmpty(Request.QueryString["menu"]) && Request.QueryString["menu"] == "filedown") { string path = Request.QueryString["filepath"]; SafeSC.DownFile(path); //if (path != "") //{ // string filepath = Server.MapPath(path); // System.IO.FileInfo file = new System.IO.FileInfo(filepath); // if (file.Exists) // { // Response.Clear(); // Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name)); // Response.AddHeader("Content-Length", file.Length.ToString()); // Response.ContentType = "application/octet-stream"; // Response.Filter.Close(); // Response.WriteFile(file.FullName); // Response.End(); // } // else // { // Response.Write("<script>alert('该文件不存在!')</script>"); // } //} } if (!IsPostBack) { MyBind(QuestionId); M_IServer iserver = serverBll.SeachById(QuestionId); iserver.ReadCount = iserver.ReadCount + 1; serverBll.Update(iserver); } Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "I/Main.aspx'>工作台</a></li><li><a href='BiServer.aspx'>有问必答</a></li><li class='active'>问题详情</li>"); }
protected void EGV_RowCommand(object sender, GridViewCommandEventArgs e) { string name = e.CommandArgument.ToString(); switch (e.CommandName) { case "download": SafeSC.DownFile(mnBll.vdir + name, name); break; case "restore": mnBll.RestoreByName(name); function.WriteSuccessMsg("恢复完成"); break; case "del2": SafeSC.DelFile(mnBll.vdir + name); function.WriteSuccessMsg("删除完成"); break; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { switch (DType) { case "design": { int siteID = DataConverter.CLng(Request.QueryString["SiteID"]); string vpath = B_Design_SiteInfo.GetSiteUpDir(siteID) + FName; if (siteID < 1 || string.IsNullOrEmpty(FName)) { function.WriteErrMsg("文件路径不正确"); } SafeSC.DownFile(vpath); } break; default: if (!string.IsNullOrEmpty(Request["File"])) //仅用于云盘Guid { string guid = Request.QueryString["File"]; M_Plat_File fileMod = fileBll.SelReturnModel(guid); SafeSC.DownFile(fileMod.VPath + fileMod.SFileName, fileMod.FileName); } else if (!string.IsNullOrEmpty(Request["CloudFile"])) { string guid = Request["CloudFile"]; M_User_Cloud cloudMod = cloudBll.SelReturnModel(guid); SafeSC.DownFile(cloudMod.VPath + cloudMod.SFileName, cloudMod.FileName); } else if (!string.IsNullOrEmpty(FName)) //其他通过来源和文件名下载 { string fname = FName.ToLower().Replace("/UploadFiles/", ""); SafeSC.DownFile("/UploadFiles/" + fname); } break; } } }
//word模板-->子iframe-->收集base64-->提交-->baseToImg-->替换域-->生成word-->返回下载 protected void WordReport_Btn_Click(object sender, EventArgs e) { //data:image/png;base64, ImgHelper imgHelp = new ImgHelper(); string key = skey_hid.Value; string title = DateTime.Now.ToString("yyyyMMdd[" + key + "]报告"); string copyright = "来自于" + Call.SiteName + "," + "http://" + Request.Url.Host + "/"; string copyright2 = "基于Zoomla!逐浪©CMS大数据挖掘分析平台生成,签名标记:" + SiteConfig.SiteOption.SenSign ?? ""; sumpie_hid.Value = Regex.Split(sumpie_hid.Value, Regex.Unescape("base64,"))[1]; timeline_hid.Value = Regex.Split(timeline_hid.Value, Regex.Unescape("base64,"))[1]; timepie_hid.Value = Regex.Split(timepie_hid.Value, Regex.Unescape("base64,"))[1]; string sumpie = "/UploadFiles/Report/sumpie" + key + ".jpg", timeline = "/UploadFiles/Report/timeline" + key + ".jpg", timepie = "/UploadFiles/Report/timepie" + key + ".jpg", wordpath = "/UploadFiles/Report/" + title + ".docx"; imgHelp.Base64ToImg(sumpie, sumpie_hid.Value); imgHelp.Base64ToImg(timeline, timeline_hid.Value); imgHelp.Base64ToImg(timepie, timepie_hid.Value); //------生成Word var doc = new Aspose.Words.Document(Server.MapPath("tlp.docx")); string[] fieldNames = "title,sumstr,sumpie,timeline,timepie,copyright,copyright2".Split(','); object[] fieldValues = new object[] { title, sumstr_hid.Value, Server.MapPath(sumpie), Server.MapPath(timeline), Server.MapPath(timepie), copyright, copyright2 }; doc.MailMerge.Execute(fieldNames, fieldValues); DataTable dt = sdataBll.SelByKey(key, ""); dt = dt.DefaultView.ToTable(false, "Title", "Source", "Link"); DataRow dr = dt.NewRow(); dr["Title"] = "标题"; dr["Source"] = "来源"; dr["Link"] = "链接"; dt.Rows.InsertAt(dr, 0); doc = SetWord(doc, dt); doc.Save(Server.MapPath(wordpath), SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Docx)); SafeSC.DownFile(wordpath); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { M_User_Plat upMod = B_User_Plat.GetLogin(); if (upMod == null) { function.WriteErrMsg("您还没有登录,不能使用该功能!"); } M_UserInfo info = buser.SelReturnModel(uid); if (info.IsNull) { function.WriteErrMsg("用户不存在!"); } M_User_Plat upMod2 = upBll.SelReturnModel(uid); if (upMod2.CompID != upMod.CompID) { function.WriteErrMsg("您没有权限下载该用户的时间线记录!"); } if (type.Equals("mht")) { HtmlHelper htmlHelp = new HtmlHelper(); string url = SiteConfig.SiteInfo.SiteUrl + "/Plat/Blog/Timeline.aspx?uids=" + uid + "&uname=" + info.UserName + "&upwd=" + info.UserPwd; string vpath = htmlHelp.DownToMHT(url, "/UploadFiles/" + info.UserName + "的时间线.mht"); SafeSC.DownFile(vpath); } else if (type.Equals("pdf")) { StringWriter sw = new StringWriter(); string url = "/Plat/Blog/TimelineToPDF.aspx?uids=" + uid + "&uname=" + info.UserName + "&upwd=" + info.UserPwd; Server.Execute(url, sw); string vpath = "/UploadFiles/" + info.UserName + "的时间线.pdf"; PdfHelper.HtmlToPdf(sw.ToString(), "", vpath); SafeSC.DownFile(vpath); } } }
public void TalkLog_Down() { DataTable dt = msgbll.SelByWhere(mu.UserID, buser.GetUserByName(Request.Form["reuser"]).UserID, Request.Form["sdate"], Request.Form["edate"]); if (dt.Rows.Count < 1) { function.WriteErrMsg("没有聊天记录,无法导出"); } StringBuilder sb = new StringBuilder(); foreach (DataRow dr in dt.Rows) { sb.Append(dr["UserName"] + dr["CDate"].ToString() + ":\r\n"); sb.Append(dr["Content"].ToString() + "\r\n"); sb.Append("---------------------------------------------------------------\r\n"); } string vpath = "/Temp/ChatHis/"; string filename = function.GetRandomString(8) + ".txt"; SafeSC.WriteFile(vpath + filename, sb.ToString()); SafeSC.DownFile(vpath + filename); SafeSC.DelFile(vpath + filename); Response.End(); }
protected void RptFiles_ItemCommand(object source, CommandEventArgs e) { string p = this.HdnPath.Value; string str2 = p + "/" + ((string)e.CommandArgument); if (e.CommandName == "DelFiles") { FileSystemObject.Delete(base.Request.PhysicalApplicationPath + str2.Replace("/", @"\"), FsoMethod.File); function.WriteSuccessMsg("文件成功删除", "../File/BackupManage.aspx?Dir=" + base.Server.UrlEncode(p)); } if (e.CommandName == "DelDir") { base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>"); FileSystemObject.Delete(base.Request.PhysicalApplicationPath + str2.Replace("/", @"\"), FsoMethod.Folder); function.WriteSuccessMsg("目录成功删除", "../File/BackupManage.aspx?Dir=" + base.Server.UrlEncode(p)); } if (e.CommandName == "Down") //下载功能 { string ste = e.CommandArgument.ToString(); //文件全名 string filetype = Path.GetExtension(ste); //文件扩展名 string ttname = Path.GetFileNameWithoutExtension(ste); //文件名 SafeSC.DownFile(str2, HttpUtility.UrlEncode(ttname + filetype, System.Text.Encoding.UTF8)); } }
public void download(string esting) { string FileToZip = Server.MapPath("/temp/" + esting + ".bak"); string ZipedFile = Server.MapPath("/temp/" + esting + ".rar"); //否则没有.bak文件,则先创建.bak文件。再进行压缩 string sPath = HttpContext.Current.Request.PhysicalApplicationPath + "/temp"; if (Directory.Exists(sPath)) { } else { Directory.CreateDirectory(sPath); } string sql = "backup database " + database + " to disk='" + sPath + "/" + esting + ".bak" + "' with init "; if (!SqlHelper.ExecuteSql(sql)) { if (ZC.Zip(FileToZip, ZipedFile)) { SafeSC.DownFile("/temp/" + esting + ".rar"); } } }
protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Del") { string LabelName = e.CommandArgument.ToString(); bll.DelLabelXML(LabelName); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Copy") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); newlbl.LableName = newlbl.LableName + DataSecurity.RandomNum(4); newlbl.LabelID = 0; bll.AddLabelXML(newlbl); Response.Redirect("LabelManage.aspx"); } if (e.CommandName == "Download") { string LabelName = e.CommandArgument.ToString(); M_Label newlbl = bll.GetLabelXML(LabelName); SafeSC.DownFile(B_Label.GetLabelVPath(newlbl), newlbl.LableName + ".lable"); } }
public void DownPaper() { string qids = Request["qids"] ?? ""; string PaperSize = Request["PaperSize"] ?? "A4"; bool Orient = string.IsNullOrEmpty(Request["Orient"]) ? true : DataConverter.CBool(Request["Orient"]); M_Exam_Sys_Papers paperMod = paperBll.SelReturnModel(Mid); if (paperMod == null) { function.WriteErrMsg("试卷不存在"); } BH.HtmlHelper htmlHelp = new BH.HtmlHelper(); StringWriter sw = new StringWriter(); Server.Execute("/BU/Exam/Paper.aspx?id=" + paperMod.id, sw, false); string html = sw.ToString(); HtmlPage page = htmlHelp.GetPage(html); html = page.Body.ExtractAllNodesThatMatch(new HasAttributeFilter("id", "paper"), true).ToHtml(); string wordDir = "/Log/Storage/Exam/Paper/"; string wordPath = wordDir + paperMod.id + ".docx"; string ppath = Server.MapPath(wordPath); if (!Directory.Exists(Server.MapPath(wordDir))) { Directory.CreateDirectory(Server.MapPath(wordDir)); } MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); //convert stream 2 string using (MemoryStream generatedDocument = new MemoryStream()) { using (WordprocessingDocument doc = WordprocessingDocument.Create(generatedDocument, WordprocessingDocumentType.Document)) { MainDocumentPart mainPart = doc.MainDocumentPart; if (mainPart == null) { mainPart = doc.AddMainDocumentPart(); new Document(new Body()).Save(mainPart); } HtmlConverter converter = new HtmlConverter(mainPart); //生成格式A4,A3 Body docBody = mainPart.Document.Body; SectionProperties sectionProperties = new SectionProperties(); PageSize pageSize = new PageSize(); PageMargin pageMargin = new PageMargin(); //默认为16k大小 Columns columns = new Columns() { Space = "220" }; //720 DocGrid docGrid = new DocGrid() { LinePitch = 100 }; //360 GetPageSetting(ref pageSize, ref pageMargin, PaperSize, Orient); sectionProperties.Append(pageSize, pageMargin, columns, docGrid); docBody.Append(sectionProperties); var paragraphs = converter.Parse(html); for (int i = 0; i < paragraphs.Count; i++) { docBody.Append(paragraphs[i]); } mainPart.Document.Save(); } SafeC.SaveFile(wordDir, paperMod.id + ".docx", generatedDocument.ToArray()); } SafeSC.DownFile(wordPath, paperMod.p_name + ".docx"); }
public void ViewPublish_Down() { M_Content_Publish cpMod = cpBll.SelReturnModel(1); SafeSC.DownFile(cpMod.AttachFile); }