using System.Diagnostics; using Syncfusion.XlsIO;
namespace MergeCells { internal class Program { static void Main(string[] args) { //Create Excel document using XlsIO ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
int firstRow = 8; int lastRow = 30;
int firstColumn = 2; int lastColumn = 3;
//Merge cells for(int row = firstRow; row <= lastRow; row++) { worksheet.Range[row, firstColumn, row, lastColumn].Merge(); }
worksheet[firstRow, firstColumn, lastRow, lastColumn].BorderAround();
workbook.SaveAs("Output.xlsx");
Process.Start("Output.xlsx"); } } } |