Merge cells using EPPlus? Merge cells using EPPlus? asp.net asp.net

Merge cells using EPPlus?


You have to use it like this:

ws.Cells["A1:C1"].Merge = true;

instead of:

using (ExcelRange rng = ws.Cells["A1:C1"]){    bool merge = rng.Merge;}


If you want to merge cells dynamically, you can also use:

worksheet.Cells[FromRow, FromColumn, ToRow, ToColumn].Merge = true;

All these variables are integers.


You can create a extension method:

public static void Merge(this ExcelRangeBase range){    ExcelCellAddress start = range.Start;    ExcelCellAddress end = range.End;    range.Worksheet.Cells[start.Row, start.Column, end.Row, end.Column].Merge = true;}

You can use this as you would via interop:

range.Merge();