-
大小: 1.96MB文件类型: .rar金币: 1下载: 0 次发布日期: 2023-09-27
- 语言: C#
- 标签: html转word Aspose.Words
资源简介
个人经典珍藏,史上最牛Asp.net将Html页面转Word(Aspose.Words)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aspose.Words;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender EventArgs e)
{
}
/// 导出模板1
///
/// 导出模板1
///
///
///
protected void btn_daoa_Click(object sender EventArgs e)
{
string tmppath = Server.MapPath(“template.doc“);
Document Maindoc = new Document();
Document doc = null;
int bh = 143139;
string zfjl = “走访记录测试 走访记录测试走访记录测试走访记录测试走访记录测试走访记录测试走访记录测试“;
for (int i = 0; i < 3; i++)
{
doc = new Document(tmppath); //载入模板
#region 主要是通过BookMark来操作,做为动态的数据的源
bh = bh + 1;
UseBookmark(doc “BH“ bh.ToString());
UseBookmark(doc “Name“ “易海军“);
UseBookmark(doc “Address“ “湖南省长沙县榔梨镇金托村白塘组467号“);
UseBookmark(doc “Age“ “56“);
UseBookmark(doc “ZZMM“ “群众“);
UseBookmark(doc “JTRK“ “4“);
UseBookmark(doc “Tell“ “13800008888“);
UseBookmark(doc “Phone“ “34523452“);
UseBookmark(doc “JJLY“ “主要经济来源及家庭收入情况“);
UseBookmark(doc “YFZGX1“ “妻子“);
UseBookmark(doc “YFZGX2“ “儿子“);
UseBookmark(doc “YFZGX3“ “女子“);
UseBookmark(doc “Name1“ “易海军1“);
UseBookmark(doc “Name2“ “易海军2“);
UseBookmark(doc “Name3“ “易海军3“);
UseBookmark(doc “Sex1“ “女“);
UseBookmark(doc “Sex2“ “男“);
UseBookmark(doc “Sex3“ “女“);
UseBookmark(doc “Age1“ “50“);
UseBookmark(doc “Age2“ “30“);
UseBookmark(doc “Age3“ “29“);
UseBookmark(doc “ZY1“ “务农“);
UseBookmark(doc “ZY2“ “务农“);
UseBookmark(doc “ZY3“ “务农“);
UseBookmark(doc “QTQK1“ “其 它 情 况1“);
UseBookmark(doc “QTQK2“ “其 它 情 况2“);
UseBookmark(doc “QTQK3“ “其 它 情 况3“);
UseBookmark(doc “HZQM“ “易海军“);
UseBookmark(doc “Year“ “2012“);
UseBookmark(doc “Month“ “04“);
UseBookmark(doc “Day“ “19“);
UseBookmark(doc “ZFRY“ “走访唐***“);
zfjl = zfjl + i.ToString();
UseBookmark(doc “Content“ zfjl);
#endregion
DocumentBuilder builder = new DocumentBuilder();
builder.Document = doc;
appendDoc(Maindoc builder); //把当前word保存到主要word中。
builder = null;
}
Maindoc.ChildNodes.RemoveAt(0); //移除第一个空白模板
Maindoc.Save(“测试模板.doc“ SaveFormat.Doc SaveType.OpenInWord Response); //保存为doc,并打开
}
/// 用Bookmark绑定word对应项的值
///
///
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1103 2012-04-19 12:40 daoword\daoword\App_Code\ExportWord.cs
文件 3418624 2012-04-13 14:56 daoword\daoword\Bin\Aspose.Cells.dll
文件 2907648 2012-04-13 14:56 daoword\daoword\Bin\Aspose.Words.dll
文件 709 2012-04-19 16:50 daoword\daoword\Default.aspx
文件 12978 2012-04-19 19:40 daoword\daoword\Default.aspx.cs
文件 41984 2012-04-19 13:37 daoword\daoword\template.doc
文件 1838 2012-04-19 14:30 daoword\daoword\Web.config
文件 37376 2012-04-19 19:39 daoword\daoword\template2.doc
文件 43105 2012-04-19 19:45 daoword\daoword\使用备注.docx
目录 0 2012-04-19 12:14 daoword\daoword\App_Code
目录 0 2012-04-19 12:13 daoword\daoword\Bin
目录 0 2012-04-19 11:06 daoword\daoword\App_Data
目录 0 2012-04-19 18:06 daoword\daoword
目录 0 2012-04-19 19:34 daoword
----------- --------- ---------- ----- ----
6465365 14
- 上一篇:C#桌面日历天气
- 下一篇:zw_WPF_开发教程(_中文版).zip
评论
共有 条评论