/// <summary>
///合并单元格,并赋值,对指定WorkSheet操作
/// </summary>
/// <paramname="beginRowIndex">开始行索引</param>
/// <paramname="beginColumnIndex">开始列索引</param>
/// <paramname="endRowIndex">结束行索引</param>
/// <paramname="endColumnIndex">结束列索引</param>
/// <paramname="text">合并后Range的值</param>
private voidMergeCells(Excel.Worksheet sheet,int beginRowIndex,intbeginColumnIndex,int endRowIndex,int endColumnIndex,stringtext)
{
if(sheet ==null)
return;
range =sheet.get_Range(sheet.Cells[beginRowIndex,beginColumnIndex],sheet.Cells[endRowIndex,endColumnIndex]);
range.ClearContents();//先把Range内容清除,合并才不会出错
range.MergeCells= true;
range.Value =text;
range.HorizontalAlignment= Excel.XlHAlign.xlHAlignCenter;
range.VerticalAlignment= Excel.XlVAlign.xlVAlignCenter;
}