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

Free Support Forum - aspose.com

MaxColumn is set to Column XFD after calling InsertCutCells()

Hello!
I would like to rearrange some rows in Excel by cutting and pasting an entire row to a different row number. I think we are running into an issue with what is considered our “Last Cell” after our code calls InsertCutCells(cutRange, row, column, shiftType). For reference, we calculate the Last Cell using this code (c#):
Worksheet.GetCell(Worksheet.Self.Cells.MaxRow, Worksheet.Self.Cells.MaxColumn);

Before calling InsertCutCells(...), calculating the “Last Cell” gives us what we would expect (the last cell in a reasonable column, such as Column AC). However, after the call to InsertCutCells(...), calculating the “Last Cell” gives us a cell in the last possible column, XFD. When cutting and pasting, what is happening to the pasted-in cells so Worksheet.Self.Cells.MaxColumn gives us the last possible column? How can I use Aspose to cut and paste a row while preserving MaxColumn?

Thank you!

@MacIverson,
Share your runnable console application along with the template file for our reference. We will reproduce the issue here and provide assistance accordingly.

Hello! I apologize for the wait. Here is the code I used to produce this issue, as well as the workbook I used. Thank you!
Example.zip (8.5 KB)

using Aspose.Cells;
using System;

namespace AsposeInsertCutCellsDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook wb = new Workbook("Example.xlsx");
            Worksheet sheet = wb.Worksheets["Sheet1"];

            var oldMaxCol = sheet.Cells.MaxColumn;

            var cutRange = sheet.Cells.CreateRange("A1").EntireRow;
            var pasteRange = sheet.Cells.CreateRange("A4").EntireRow;

            sheet.Cells.InsertCutCells(
                cutRange: cutRange,
                row: pasteRange.FirstRow,
                column: pasteRange.FirstColumn,
                shiftType: ShiftType.Down);

            var newMaxCol = sheet.Cells.MaxColumn;

            if (oldMaxCol != newMaxCol)
            {
                throw new Exception("MaxColumn was not preserved");
            }
        }
    }
}

@MacIverson,
This issue is reproduced using the sample code and template file. It is logged in our database for an investigation and a fix. You will be notified here once any update is ready to share.

This issue is logged under Id:
CELLSNET-47581 - MaxColumn is set to Column XFD after calling InsertCutCells()

@MacIverson,
This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-47581”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

Hello! Thank you, that is much appreciated!

@MacIverson,
Please try our latest version/fix: Aspose.Cells for .NET v20.8.9 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells20.8.9 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.8.9 For .Net4.0.Zip (5.4 MB)

Hello! The issue is resolved on my end with this new version! Thank you very much, I really appreciate your time and effort.

@MacIverson,
Thanks for your feedback and using Aspose.Cells. It is good to know your issue is resolved now. Let us know if you encounter any issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as CELLSNET-47581) have been fixed in Aspose.Cells for .NET v20.9. This message was posted using Bugs notification tool by Amjad_Sahi
You may also get the new version @ nuget repos. (https://www.nuget.org/packages/Aspose.Cells/20.9.0)