文档详情

npoi,按模板导出word.doc

发布:2016-12-28约9.38千字共17页下载文档
文本预览下载声明
npoi,按模板导出word 篇一:Npoi2.0.5导出word(合并行和合并列 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Text; using System.Data; using System.Collections; using System.IO; using NPOI; using NPOI.HSSF.UserModel; using DAL = CC.DAL; using CC.Common; using BLL = CC.BLL; using NPOI.XWPF.UserModel; using NPOI.OpenXml4Net; using NPOI.OpenXmlFormats.Wordprocessing; /******************** * 功能:食谱分析报告导出 * 编写人: * 日期:2014.5.27 * nopi版本: ********************/ public partial class ExportFoodCheckList : BasePage { #region //加载模板 protected void Page_Load(object sender, EventArgs e) { if (Request[RecweekId] != null) { string type = Request[type].ToString(); int RecweekId = int.Parse(Request[RecweekId].ToString()); ViewState[HidRecipwweekId] = RecweekId.ToString(); if (type == Rec) { XWPFDocument doc = HtmlExport(Int32.Parse(ViewState[HidRecipwweekId].ToString()), 0);//.Replace(lt;table border=#39;0#39; class=#39;table_food mt10#39;, lt;table border=#39;1#39; );//this.DivContent.InnerHtml.ToString().Replace(lt;table border=#39;0#39; class=#39;table_food mt10#39;, lt;table border=#39;1#39; ); string wordFile = Server.MapPath(模板.docx); FileInfo file = new FileInfo(wordFile); if (file.Exists) { FileStream out1 = new FileStream(wordFile, FileMode.Create);doc.Write(out1); out1.Close(); openWindowExport(wordFile, 食谱.docx); } } else { XWPFDocument doc = new XWPFDocument(); string wordFile = Server.MapPath(模板.docx); FileInfo file = new FileInfo(wordFile); if (file.Exists){ doc = tbGetReport(Int32.Parse(ViewState[HidRecipwweekId].ToString()), doc); FileStream out1 = new FileStream(wordFile, FileMode.Create); doc.Write(out1); out1.Close(); openWindowExport(wordFile, 食谱分析报告.docx); } } } } public static string openWindowExport(string strFileName,string downfile) { string strReutrn = ; try { FileInfo DownloadFile = new FileInfo(strFileName); System.Web.HttpContext.Current.
显示全部
相似文档