Cells.InsertCutCells breaks on workbooks with a range intersection

Hi, we’re running into an issue where the latest Aspose.Cells for .NET crashes when Cells.InsertCutCells() is called. Specifically, the crash only occurs in files which contain a formula that intersects 2 ranges.

For example, the formula =NamedRange1 NamedRange2 returns the intersection of NamedRange1 and NamedRange2.

If InsertCutCells() is called on a workbook that contains a range intersection like that, it throws the following exception:

Aspose.Cells.CellsException: 'Invalid reference for sign ’ ‘(Based on cell Sheet1!E2)’

The intersection does not need to be inside the range that is being cut by InsertCutCells() for this to occur.

Code:

var workbook = new Aspose.Cells.Workbook("C:\\scratch\\AsposeIntersectionRepro.xlsx");
var sheet = workbook.Worksheets["Sheet1"];
var range = sheet.Cells.CreateRange("A1");
sheet.Cells.InsertCutCells(range, range.FirstRow + 1, range.FirstColumn + 1, Aspose.Cells.ShiftType.Down);

File:
AsposeIntersectionRepro.zip (6.6 KB)

Version info: I have reproduced this on Aspose.Cells for .NET version 20.5.0 and 19.10.0. I had to do some work to extract the 20.5.0 DLL from your NuGet package, because the 20.5.0 package on NuGet is currently broken for .NET Core as per this issue.

@rwood,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-47385 - Cells.InsertCutCells breaks on workbooks with a range intersection
1 Like

@rwood,
Please try our latest version/fix: Aspose.Cells for .NET v20.5.3:
Aspose.Cells20.5.3 For .Net4.0.Zip (5.4 MB)
Aspose.Cells20.5.3 For .Net2_AuthenticodeSigned.Zip (5.4 MB)

Your issue should be fixed in it.

Let us know your feedback.

Thank you for the prompt responses, Ahsan. I attempted to use the 20.5.3 DLL from your Aspose.Cells20.5.3 For .Net2_AuthenticodeSigned.Zip file, but it fails to load my AsposeIntersectionRepro.xlsx file:

Aspose.Cells.CellsException: 'The file is corrupted.'

I do not believe the file is not corrupted, it can be opened in Excel without issue and I created it from scratch for this bug report.

@rwood,

I tested your scenario/case using the same Dll with your template file (you attached in the first post of the thread) and sample code, it works fine and I do not get any exception. Please make sure that you are using the latest fix/version: Aspose.Cells for .NET v20.5.3, you may print the version number to confirm you are using the correct version:
e.g
Sample code:

 Console.WriteLine(CellsHelper.GetVersion());
            var workbook = new Aspose.Cells.Workbook("e:\\test2\\AsposeIntersectionRepro.xlsx");
            var sheet = workbook.Worksheets["Sheet1"];
            var range = sheet.Cells.CreateRange("A1");
            sheet.Cells.InsertCutCells(range, range.FirstRow + 1, range.FirstColumn + 1, Aspose.Cells.ShiftType.Down);

I can confirm that I am using v20.5.3. This is occurring in a .NET Core 3.1 console project, and it seems to occur on any spreadsheet not just the one I uploaded. I am copying the DLL to the solution folder and referencing it in the .csproj file like so:

    <Reference Include="Aspose.Cells">
      <HintPath>..\Aspose.Cells.dll</HintPath>
    </Reference>

A screenshot of the exception occurring:
image.png (40.4 KB)

@rwood,

Well, you are trying to use common .NET 2.0 fix in .NET core application which won’t work. You need to have Aspose.Cells for .NET Core/.NET Standard fix. Please wait we we will check if we can provide you the Aspose.Cells for .NET Standard fix in the next few days. Alternatively, you have to wait for our next official release, i.e., Aspose.Cells for .NET 20.6 (it includes .NET Standard 2.0 library as well), the release is due in the third week of June, 2020.

Thanks! I’m happy to wait for the next release.

@rwood,

We have prepared a hotfix version for your needs, please find attached the Aspose.Cells for .NET Standard fix and try it, it will work fine.

Let us know your feedback.
Aspose.Cells20.5.3 For .NetStandard20.Zip (5.3 MB)

Thank you Amjad! I can confirm that this fixes the issue.

@rwood,

Thanks for your feedback.

Please feel free to ask if you have any questions or comments, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSNET-47385) have been fixed in Aspose.Cells for .NET v20.6. you may also get the version @ NuGet repos. here (NuGet Gallery | Aspose.Cells 20.6.0).This message was posted using Bugs notification tool by Amjad_Sahi

The issues you have found earlier (filed as CELLSNET-47385) have been fixed in Aspose.Cells for .NET v20.6. you may also get the version @ NuGet repos. here (NuGet Gallery | Aspose.Cells 20.6.0).This message was posted using Bugs notification tool by Amjad_Sahi