Range sliding

Hi,

I’m currently working with Aspose.Excel 2.9.0.1.

When I add a range a worksheet, and then add a row above it later on, the startrow of the range is not updated.

Is it possible to have the ranges slide with the addition of new rows, as it currently works in Excel?

Thanks,

Paul

Hi Paul,

You can insert row first then add a range.

This change may affect many users. If I change the code and they upgrade to the new version, their previous code will have to be changed.

I understand the code compatibility issue.

Adding range sliding would definitely be useful for users who load templates with ranges predefined (like me). Would it be possible to add a boolean hook into the Excel component that would let the user define whether he/she wishes for ranges to slide (it could be defaulted to false to insure compatibility with existing code bases).

Thanks,

Paul

@intersoft_dc,
Aspose.Excel has replaced Aspose.Cells that is no more actively developed now and is discarded. Using Aspose.Cells it is possible to create ranges and insert rows similar to MS Excel where the range will slide if we insert a row. The following code sample demonstrates this feature where the range will slide after inserting a row above the range.

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Cells.ImportObjectArray(Enumerable.Range(1, 6).Cast<object>().ToArray(),
    0, //this table is start at row 0
    0, false);

var headerRange = sheet.Cells.CreateRange(0, 0, 1, 6);
headerRange.Name = "MyRange";
workbook.Save("BeforeInsertRow.xlsx");
sheet.Cells.InsertRow(0);
workbook.Save("AfterInsertRow.xlsx");

Here you can observe the named range ‘MyRange’ slides when a row is inserted above the range.

Download the latest free trial version of this new product here:
Aspose.Cells for .NET (Latest Version)

Download an example project here that can be used to test the variety of features of this new product.