一、word
这是我以前工作时写过的一个业务逻辑处理类,里面有不少文件操作的方法,这里主要关注一下C#对word的操作。里面的方法可以直接拿出来用,主要是通过word的dot模版来进行创建word、替换word等操作。
namespace Excel2Word
{
public class BLL
{
private Microsoft.Office.Interop.Word.Application app = null;//全局变量 word应用程序
/// <summary>
/// 从Excel中读取数据
/// </summary>
/// <param name="excelPath"></param>
/// <param name="sheetName"></param>
/// <returns></returns>
public static DataSet GetDataFromExcel(string excelPath, string sheetName)
{
DataSet ds = new DataSet();
string strConn = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" + excelPath.ToString().Trim() + "; Extended Properties=Excel 8.0;";
try
{
using (OleDbConnection conn = ne