Free Support Forum -

DeleteRange() Problem (Not Working)

Hello, thank you in advance for your help.

I am having an issue using DeleteRange(). I currently have a spreadsheet where based on specific conditions, i want to delete a specific range of cells and shift the remaining cells left. This is done row by row. However, as i apply the deleteRange call, the cells are not deleting. Do i need to remove all data, formats, styles etc prior to using this method?

Thank you.


Here is the code:

getCells = commWorkbook.Worksheets[SheetPage2].Cells;

getCells.DeleteRange(IntRangeVal, 8, IntRangeVal, 9, shiftCellsLeft);


IntRangeVal = integer Value representing the row where cells are to be deleted

shiftCellsLeft = variable declared Globally as the following

tExcel.ShiftType shiftCellsLeft = tExcel.ShiftType.Left;

Where tExcel is declared as:

using tExcel = Aspose.Cells;

This message was posted using Aspose.Live 2 Forum


Well, I have tested your scenario with the following sample code and it works fine. The Cells.DeleteRange() works as expected. I have also attached the input and output files.

Sample Code:
Workbook workbook = new Workbook();
Worksheets worksheets = workbook.Worksheets;
Worksheet worksheet = workbook.Worksheets[0];
//Delete Range i.e. F6:H10
worksheet.Cells.DeleteRange(5, 5, 9, 7, ShiftType.Left);


I am using Aspose.Cells for .NET v4.8.2, kindly try it:

If you still find the issue, do create a sample code and attach your input(if you have) and output files. We will check your issue soon.

Thank you.

Thank you for your quick response.