Free Support Forum - aspose.com

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.

Dan

Here is the code:

getCells = commWorkbook.Worksheets[SheetPage2].Cells;

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

Where:

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

Hi,

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();
workbook.Open(@“e:\test\bkRange.xls”);
Worksheets worksheets = workbook.Worksheets;
Worksheet worksheet = workbook.Worksheets[0];
//Delete Range i.e. F6:H10
worksheet.Cells.DeleteRange(5, 5, 9, 7, ShiftType.Left);

workbook.Save(“e:\test\out__bkRange.xls”);


I am using Aspose.Cells for .NET v4.8.2, kindly try it: http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry215207.aspx


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.