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

Free Support Forum - aspose.com

DeleteRange doesn't handle validation correctly

I am glad that Aspose recently fixed the issue discussed in <a href="</a></div><div><br></div><div>However, there is still a similar bug: If I use DeleteRange(ShiftLeft), the cells that are located to the right of the deleted range (and thus shifted left), loses its validation.</div><div><br></div><div>See the attached code and XLSX-file.</div><div>Note that the cell L4 contains a validation, which gets lost in the resulting document.</div><div><br></div><div>Thanks!<br>/Fredrik</div><div><div>using System;</div><div>using System.Collections.Generic;</div><div>using System.Linq;</div><div>using System.Text;</div><div>using Aspose.Cells;</div><div>using System.Data;</div><div>using System.Diagnostics;</div><div><br></div><div>namespace Infoweaver.Forms.AsposeTest</div><div>{</div><div> class DeleteRange</div><div> {</div><div> public enum DeleteRangeEnum</div><div> {</div><div> ShiftCellsLeft,</div><div> ShiftCellsUp,</div><div> DeleteEntireColumns,</div><div> DeleteEntireRows</div><div> }</div><div> public static void DoIt()</div><div> {</div><div> WorkbookDesigner designer = new WorkbookDesigner();</div><div> Workbook workbook = new Workbook(Constants.sourcePath + "DeleteRange2.xlsx");
designer.Workbook = workbook;

Range range = workbook.Worksheets.GetRangeByName("DUP_Project");
Worksheet worksheet = range.Worksheet;

Cells cells = range.Worksheet.Cells;

DeleteRangeEnum mode = DeleteRangeEnum.ShiftCellsLeft;

switch (mode)
case DeleteRangeEnum.ShiftCellsLeft:
case DeleteRangeEnum.ShiftCellsUp:
ShiftType shiftType = mode == DeleteRangeEnum.ShiftCellsLeft ? ShiftType.Left : ShiftType.Up;
cells.DeleteRange(range.FirstRow, range.FirstColumn, range.FirstRow + range.RowCount - 1, range.FirstColumn + range.ColumnCount - 1, shiftType);
case DeleteRangeEnum.DeleteEntireColumns:
cells.DeleteColumns(range.FirstColumn, range.ColumnCount, true);
case DeleteRangeEnum.DeleteEntireRows:
cells.DeleteRows(range.FirstRow, range.RowCount, true);
throw new InvalidOperationException(string.Format("Unexpected DeleteRangeEnum: '{0}'.", mode));
string output = Constants.destPath + "DeleteRange2_result.xlsx";


I have tested your issue and found the issue using your template file and code segment. I have logged a ticket for the issue with an id: CELLSNET-31333. We will look into it soon.

Thank you.


We have fixed this issue. Please download: Aspose.Cells for .NET v7.0.4.3