C# XML导出Word方法
最近写的一个通过XML导出Word的方法,共大家参考讨论:
方法的调用:
Dictionary<string, string> wordTexts = new Dictionary<string, string>();
Dictionary<string, DataTable> wordTable = new Dictionary<string, DataTable>();
WordMLHelper Word = new WordMLHelper();
wordTexts.Clear();
wordTexts.Add("XML中书签名称",“导出的内容”);
Word.SetNodeText(wordTexts);
DataTable dt=getDateTable();//获得一个数据表
wordTable.Clear();
wordTable.Add("XML中书签名称", dt);
Word.SetNodeTable(wordTable);
Word.Save("存储地址");
操作类的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Drawing;
using System.IO;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web;
/// <summary>
/// 导出word
/// Author:FreezeSoul&Worm
/// 操作WordML(2003)根据标签插入文本、表格、图片
/// </summary>
public class WordMLHelper
{
/// <summary>
/// 最短路径图片在导出Word文件中的宽度
/// webconfig中加入节点 <add key ="WordWidth" value="400"/>
/// </summary>
public string WordWidth
{
get
{
return System.Configuration.ConfigurationSettings.AppSettings["WordWidth"].ToString();
}
}
/// <summary>
/// 最短路径图片在导出Word文件中的高度
/// webconfig中加入节点<add key ="WordHeight" value="300"/>
/// </summary>
public
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Drawing;
using System.IO;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web;
/// <summary>
/// 导出word
/// Author:FreezeSoul&Worm
/// 操作WordML(2003)根据标签插入文本、表格、图片
/// </summary>
public class WordMLHelper
{
/// <summary>
/// 最短路径图片在导出Word文件中的宽度
/// webconfig中加入节点 <add key ="WordWidth" value="400"/>
/// </summary>
public string WordWidth
{
get
{
return System.Configuration.ConfigurationSettings.AppSettings["WordWidth"].ToString();
}
}
/// <summary>
/// 最短路径图片在导出Word文件中的高度
/// webconfig中加入节点<add key ="WordHeight" value="300"/>
/// </summary>
public
补充:软件开发 , C# ,