We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert new row with above merged cells

I’m trying to insert new row in the existing excel template,But merged cells are not copying in the new row, I’m using below code to insert new row, Please tell me the workaround


_worksheet.Cells.InsertRow(rowIndex);

Hi,


Thank you for contacting Aspose support.

If the existing row has merged cells and you wish to get the same effect in the newly inserted row then please use Cells.CopyRow instead of Cells.InsertRow method. Please check the following piece of code along with input & output spreadsheets (attached).

C#

var book = new Workbook(dir + “book1.xlsx”);
var sheet = book.Worksheets[0];
//Copy first row to second index
sheet.Cells.CopyRow(sheet.Cells, 0, 1);
book.Save(dir + “output.xlsx”);