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

Free Support Forum - aspose.com

Excel Sheet - after merge Insert and Delete row is disabled


I have an issue when I merge 2 worskheets in 1.
The merge works fine, but when I right-click on a row, it’s impossible to Insert or delete a row, could you please advice?


Below is my code:

Workbook destWorkbook = new Workbook();
Worksheet destSheet = destWorkbook.Worksheets[0];

        using (MemoryStream m1 = new MemoryStream(templateFile))
            Workbook workBook = new Workbook(m1, new LoadOptions(LoadFormat.Xlsx));

            Worksheet claimsFiledWorksheet;
            claimsFiledWorksheet = workBook.Worksheets[0];
            FillClaimsFiledSheet(claimsFiledWorksheet, claimsFileds, reportFilter, dashboard.CompanyId);

            PasteOptions options = new PasteOptions
                PasteType = PasteType.All

            Range sourceRange = sourceSheet.Cells.MaxDisplayRange;
            Range destRange = destSheet.Cells.CreateRange(sourceRange.FirstRow, sourceRange.FirstColumn, sourceRange.RowCount, sourceRange.ColumnCount);

            destRange.Copy(sourceRange, options);
            var totalColumnCount = sourceSheet.Cells.MaxDataColumn;
            sourceRange = claimsFiledWorksheet.Cells.MaxDisplayRange;
            destRange = destSheet.Cells.CreateRange(sourceRange.FirstRow, sourceRange.FirstColumn + totalColumnCount + 1, sourceRange.RowCount, sourceRange.ColumnCount);
            destRange.Copy(sourceRange, options);

            destSheet.ActiveCell = "A1";
            destSheet.Name = sourceSheet.Name;

            destSheet.Protection.AllowEditingContent = true;
            destSheet.Protection.AllowEditingObject = true;
            destSheet.Protection.AllowEditingScenario = true;

            destSheet.Protection.AllowDeletingRow = true;
            destSheet.Protection.AllowDeletingColumn = true;
            destSheet.Protection.AllowInsertingColumn = true;
            destSheet.Protection.AllowInsertingRow = true;

            WorkbookUtil.CopyStyleFirstRow(destSheet, firstDataRow, destSheet.Cells.MaxDataColumn);
            using (MemoryStream m2 = new MemoryStream())
                destWorkbook.Save(m2, SaveFormat.Xlsx);


We cannot evaluate your issue precisely as we do not have your template (source) Excel file. Moreover, you sample code cannot be compiled due to missing definition of some procedures/method(s) and objects with data. We request you to kindly provide a standalone sample VS.NET console application, zip the project (please exclude Aspose.Cells.Dll to minimize the size of the archive) and post us with sample and resource files (input Excel file, output file, etc.). We will check and help you soon. By the way, see the code segment, why you are using Protection attributes if you do not want to protect the sheet in any case?

PS. please attach the zipped archive(s) using “Upload” tool in the frame while replying to the post.