-
大小: 3.03MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-11-15
- 语言: ASP
- 标签: Aspose.Words
资源简介
.net 中导出word的工具。Aspose.Word 导出到word、pdf
代码片段和文件信息
/* ==============================================================================
* 文 件 名:Program
* 功能描述:
* Copyright (c) 2013 武汉经纬视通科技有限公司
* 创 建 人: alone
* 创建时间: 2013/4/2 11:16:19
* 修 改 人:
* 修改时间:
* 修改描述:
* 版 本: v1.0.0.0
* ==============================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Regularexpressions;
using Aspose.Words;
namespace WordDemo
{
class Program
{
static void Main(string[] args)
{
var dic = new Dictionary();
dic.Add(“姓名“ “杨幂“);
dic.Add(“学历“ “本科“);
dic.Add(“联系方式“ “02759597666“);
dic.Add(“邮箱“ “304885433@qq.com“);
dic.Add(“头像“ “.//1.jpg“);
//使用书签操作
Document doc = new Document(“.//1.doc“);
DocumentBuilder builder = new DocumentBuilder(doc);
foreach (var key in dic.Keys)
{
builder.MoveToBookmark(key);
if (key != “头像“)
{
builder.Write(dic[key]);
}
else
{
builder.InsertImage(dic[key]);
}
}
doc.Save(“书签操作.doc“);//也可以保存为1.doc 兼容03-07
Console.WriteLine(“已经完成书签操作“);
//使用特殊字符串替换
doc = new Document(“.//2.doc“);
foreach (var key in dic.Keys)
{
if (key != “头像“)
{
var repStr = string.Format(“&{0}&“ key);
doc.Range.Replace(repStr dic[key] false false);
}
else
{
Regex reg = new Regex(“&头像&“);
doc.Range.Replace(reg new ReplaceAndInsertImage(“.//1.jpg“) false);
}
}
doc.Save(“字符串替换操作.doc“);//也可以保存为1.doc 兼容03-07
Console.WriteLine(“已经完成特殊字符串替换操作“);
Console.ReadKey();
}
}
public class ReplaceAndInsertImage : IReplacingCallback
{
///
/// 需要插入的图片路径
///
public string url { get; set; }
public ReplaceAndInsertImage(string url)
{
this.url = url;
}
public ReplaceAction Replacing(ReplacingArgs e)
{
//获取当前节点
var node = e.MatchNode;
//获取当前文档
Document doc = node.Document as Document;
DocumentBuilder builder = new DocumentBuilder(doc);
//将光标移动到指定节点
builder.MoveTo(node);
//插入图片
builder.InsertImage(url);
return ReplaceAction.Replace;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-04-02 10:37 WordDemo\
目录 0 2013-04-02 11:17 WordDemo\WordDemo\
文件 914 2013-04-02 10:37 WordDemo\WordDemo.sln
文件 18432 2013-04-02 11:26 WordDemo\WordDemo.v11.suo
文件 4007424 2013-04-02 10:38 WordDemo\WordDemo\Aspose.Words.dll
目录 0 2013-04-02 10:38 WordDemo\WordDemo\bin\
目录 0 2013-04-02 12:04 WordDemo\WordDemo\bin\Debug\
文件 26624 2013-04-02 11:14 WordDemo\WordDemo\bin\Debug\1.doc
文件 76607 2013-04-02 11:15 WordDemo\WordDemo\bin\Debug\1.jpg
文件 26624 2013-04-02 11:31 WordDemo\WordDemo\bin\Debug\2.doc
文件 4007424 2013-04-02 10:38 WordDemo\WordDemo\bin\Debug\Aspose.Words.dll
文件 6656 2013-04-02 12:03 WordDemo\WordDemo\bin\Debug\WordDemo.exe
文件 13824 2013-04-02 12:03 WordDemo\WordDemo\bin\Debug\WordDemo.pdb
文件 21464 2013-04-02 10:58 WordDemo\WordDemo\bin\Debug\WordDemo.vshost.exe
目录 0 2013-04-02 10:38 WordDemo\WordDemo\bin\Release\
目录 0 2013-04-02 10:37 WordDemo\WordDemo\obj\
目录 0 2013-04-02 12:03 WordDemo\WordDemo\obj\Debug\
文件 5943 2013-04-02 11:17 WordDemo\WordDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2013-04-02 10:37 WordDemo\WordDemo\obj\Debug\TempPE\
文件 433 2013-04-02 12:03 WordDemo\WordDemo\obj\Debug\WordDemo.csproj.FileListAbsolute.txt
文件 8877 2013-04-02 12:03 WordDemo\WordDemo\obj\Debug\WordDemo.csprojResolveAssemblyReference.cache
文件 6656 2013-04-02 12:03 WordDemo\WordDemo\obj\Debug\WordDemo.exe
文件 13824 2013-04-02 12:03 WordDemo\WordDemo\obj\Debug\WordDemo.pdb
文件 3208 2013-04-02 11:44 WordDemo\WordDemo\Program.cs
目录 0 2013-04-02 10:38 WordDemo\WordDemo\Properties\
文件 1354 2013-04-02 10:37 WordDemo\WordDemo\Properties\AssemblyInfo.cs
文件 2634 2013-04-02 11:28 WordDemo\WordDemo\WordDemo.csproj
- 上一篇:个人网站设计与实现
- 下一篇:Asp网站模板 界面优美
相关资源
- Aspose(Word 18.7Cell 18.4) for .Net 破解版
- Aspose.Words.dll最新破解版,完美去水印
- Aspose.Words.18.11.0--破解版
- aspose.words 18.7破解版18年7月最新版本
- Aspose.Words 19.11.net core 可用
- Aspose.Words.dll 18.7破解版
- Aspose.Words.chm 帮助文档
- Aspose.Words V13.3 破解版
- aspose.words操作word 一些关键方法
- Aspose.Words根据word模板写入数据和图表
- Aspose.Words.dll文件.zip
- Aspose.Words帮助API
- Aspose.Words.dll155229
- Aspose.Words.dll
- Aspose.Words.dll 和帮助手册
- Aspose.Words
- Aspose.Words 16.7 for .NET 破解版已加强名
- Aspose.Words + Aspose.Cells + Aspose.Slides 19
- 各个版本破解版Aspose.Words.dll
- aspose.words 18.7破解版含net 和core 2.0版本
- Aspose.Words for .NET 18.7 破解版去除水印
- Aspose.Words 去水印版
- Aspose.words .net 18.7破解版真实可用
- Aspose.Words.dll .net 最新破解版 支持插入
- Aspose.Words18.4破解版
- Aspose.Words2017破解版DLL
- (2018.11最新破解版)Aspose.Words 18.11破
- Aspose.Words 19.3.0.0版本破解完美无水印
- aspose.words 18.4破解版
评论
共有 条评论