Insertion of rows using memory setting as MEMORY_PREFERENCE in Aspose.cells

Hi Team,

Insersion of rows not working as expected after applying MemorySetting.MEMORY_PREFERENCE.

If I apply memory setting to NORMAL, dataStartCell automatically get assigned to B$23 from B$21 after inserting two rows.

If I apply memory setting to MEMORY_PREFERENCE, dataSatrtCell get assigned to B$21 itself, not get changed.

Kindly find the attached samle code and input xlsx.

Your early response is highly appreciable.

Thanks,

Gauri

Hi Gauri,

Thanks for your posting and using Aspose.Cells.

I was able to observe this issue with the following code. It seems when Memory Preference is set then mechanism of inserting rows get changed internally. It might not be a bug but it could be some internal behavior.

We have logged this issue in our database for investigation. We will look into it and advise you. Once, there is some update for you or if it needs to be fixed, we will let you know asap.

This issue has been logged as CELLSJAVA-40847.

I have also shown the console output first achieved normally and then achieved with memory preference for a reference.

Java


Workbook workbook = new Workbook();


Worksheet worksheet = workbook.getWorksheets().get(0);


//Uncomment this line to get output with Memory Preference

// worksheet.getCells().setMemorySetting(MemorySetting.MEMORY_PREFERENCE);


Cell cell = worksheet.getCells().get(“B2”);


System.out.println(“Before Insert Rows - Cell Name:” + cell.getName());


worksheet.getCells().insertRows(0, 2);


System.out.println(“After Insert Rows - Cell Name:” + cell.getName());

Console Output With Normal
Before Insert Rows - Cell Name:B2
After Insert Rows - Cell Name:B4

Console Output With Memory Preference
Before Insert Rows - Cell Name:B2
After Insert Rows - Cell Name:B2

Hi Mshakeel,

Thanks for your quick assistant.

We observed insersion and deletion of rows not working normally, while we use memory setting to PREFERENCES.

Regards,

Gauri

Hi,


Well, this is not a bug but internal changed behavior. Please read the release note of version v8.0.0 @" http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry534643.aspx, see the section about this topic/sub-topic “Implementations of Row/Cell/RowCollection is changed” for your reference. This is not a bug but a required change that we made in the internal implementation for performance considerations.

Thanks for your understanding!

Hi Amjad,

Thanks for your updates. So after applying memory prefernces, I need to forcefully move the Cells if I am inserting rows.

Can you please guide me in case of deleting rows. As I am trying to delete some rows from my worksheet after applying memory preferences, it's not working as expected. If I tried to open that excel file after deleting rows, I get error like 'excel found unreadable content. Do you want to recovert the content of workbook?'. If I click yes, I am getting workbook without deleting that rows.

Is there any workaround for deletion of rows in memory preference scenario.

Thanks in advance.

Regards,

Gauri

Hi,


Well, It might be due to the internal behavior and implementation which is changed for rows/cols and cells in newer versions for performance grounds.

Thank you.

Hi,

For your information, for cell reference after inserting/deleting operations, you have to calculate the new position of cells by yourself. In fact even with NORMAL memory settings, the updating of cell reference may have the same issue, especially when you are inserting/deleting ranges. So, as we
declared in the release note of v8.0.0, it is better for user to avoid keep and reuse Row/Cell objects around the inserting/deleting operations. For the invalid Excel file generated by Aspose.Cells component after deleting rows, please send us your runnable program to reproduce the issue on our end, we will check whether it is a bug and provide you a solution.

Thank you.