贷款网站源码下载淘宝客网站开发定制
贷款网站源码下载,淘宝客网站开发定制,网站首页流程图,做服装商城网站NPOI 是 POI 项目的 .NET 版本。POI是一个开源的Java读写Excel、WORD等微软OLE2组件文档的项目。 使用 NPOI 你就可以在没有安装 Office 或者相应环境的机器上对 WORD/EXCEL 文档进行读写 NPOI下载地址#xff1a;http://npoi.codeplex.com/ 以下代码仅供参考#xff0c;请根…NPOI 是 POI 项目的 .NET 版本。POI是一个开源的Java读写Excel、WORD等微软OLE2组件文档的项目。 使用 NPOI 你就可以在没有安装 Office 或者相应环境的机器上对 WORD/EXCEL 文档进行读写 NPOI下载地址http://npoi.codeplex.com/ 以下代码仅供参考请根据实际需求进行修改。 public MemoryStream Export(){string filepath Server.MapPath(/word/xmxx.docx);using (FileStream stream File.OpenRead(filepath)){XWPFDocument doc new XWPFDocument(stream);//遍历段落foreach (var para in doc.Paragraphs){ReplaceKey(para);}//遍历表格var tables doc.Tables;foreach (var table in tables){foreach (var row in table.Rows){foreach (var cell in row.GetTableCells()){foreach (var para in cell.Paragraphs){ReplaceKey(para);}}}}using (MemoryStream ms new MemoryStream()){doc.Write(ms);return ms;}}}private void ReplaceKey(XWPFParagraph para){BLL.XmxxBLL XmxxBLL new BLL.XmxxBLL();Model.Xmxx model new Model.Xmxx();model XmxxBLL.GetModel(20);string text para.ParagraphText;var runs para.Runs;string styleid para.Style;for (int i 0; i runs.Count; i){var run runs[i];text run.ToString();Type t model.GetType();PropertyInfo[] pi t.GetProperties();foreach (PropertyInfo p in pi){if (text.Contains({$xmxx. p.Name })){text text.Replace({$xmxx. p.Name }, TM.Common.StringHelper.ToString(p.GetValue(model, null)));}}runs[i].SetText(text, 0);}}protected void Button1_Click(object sender, EventArgs e){using (MemoryStream ms Export()){Response.ContentType application/vnd.ms-word;Response.ContentEncoding Encoding.UTF8;Response.Charset ;Response.AppendHeader(Content-Disposition, attachment;filename HttpUtility.UrlEncode(123.doc, Encoding.UTF8));Response.BinaryWrite(Export().GetBuffer());Response.End();}} 转载于:https://www.cnblogs.com/tangxueyang/p/4741430.html
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/88298.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!