0. 导入命名空间:
using
Microsoft.Office.Core;
using
Microsoft.Office.Interop.Excel;
using
System.IO;
using
System.Reflection;
0.合并竖着的单元格
Range rangeLecture = worksheet.get_Range(worksheet.Cells[1, 1], worksheet.Cells[2, 1]); rangeLecture.Application.DisplayAlerts = false; rangeLecture.Merge(Missing.Value); rangeLecture.Application.DisplayAlerts = true;
1.合并横着的单元格
Range rangeProgram = worksheet.get_Range(worksheet.Cells[1, 1], worksheet.Cells[1, 2]);
rangeProgram.Application.DisplayAlerts = false;
rangeProgram.Merge(Missing.Value);
rangeProgram.Application.DisplayAlerts = true;