#region 公共方法
#region ExcelHelper
/// <summary>
/// 构造函数,将一个已有Excel工作簿作为模板,并指定输出路径
/// </summary>
/// <param name="templetFilePath">Excel模板文件路径</param>
/// <param name="outputFilePath">输出Excel文件路径</param>
public ExcelHelper(string templetFilePath,string outputFilePath)
{
if(templetFilePath == null)
throw new Exception("Excel模板文件路径不能为空!");
if(outputFilePath == null)
throw new Exception("输出Excel文件路径不能为空!");
if(!File.Exists(templetFilePath))
throw new Exception("指定路径的Excel模板文件不存在!");
this.templetFile = templetFilePath;
this.outputFile = outputFilePath;
//创建一个Application对象并使其可见
beforeTime = DateTime.Now;
app = new Excel.ApplicationClass();
app.Visible = true;
afterTime = DateTime.Now;
//打开模板文件,得到WorkBook对象
workBook = app.Workbooks.Open(templetFile,missing,missing,missing,missing,missing,
missing,missing,missing,missing,missing,missing,missing);
//得到WorkSheet对象
workSheet = (Excel.Worksheet)workBook.Sheets.get_Item(1);
}