npoi word生成HTML,npoi,按模板导出word.doc

这篇博客介绍了如何利用Npoi库在C#中按模板导出Word文档,包括合并行和列的功能。作者提供了代码示例,展示如何根据不同的类型导出食谱分析报告或食谱。导出过程中,首先加载模板,然后将数据写入模板并保存为新的Word文件。
摘要由CSDN通过智能技术生成

npoi,按模板导出word

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(

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.Http

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值