Sorting within groups does not work

Hello,

It seems that if some rows of my spreadsheet are grouped, then sorting any section of those rows produces strange results. It seems that the rows I'm attempting to sort become cleared and removed from the group. In Excel, sorting in these scenarios works as expected. Is there a way to make this work?

Please see attached files for the code I'm using, and my test input and output files. In addition, I was unable to remove the row groupings through code; possibly my code is wrong? The call to UngroupRows gave a null reference exception.

Mishelle

I forgot to mention, if I try to sort a range that includes grouped and nongrouped rows (e.g. rows 9:12 on my test input file), I also get a null reference exception.

Hi,

I can find the issue using your template file with your sample code.

We will look into your issue and get back to you soon.

Your issue has been logged into our issue tracking system with an issue id: CELLSNET-17907.

Thank you.

Hi,

Please try the attached version, we have fixed your issue.

Thank you.

Thanks. I tried the attached and it did not completely solve my problem. It now works correctly when the rows I'm sorting are part of a group, but if I try to sort the entire group (Case 2 on my test sheet) I now get a null ref exception.

Also I'm still getting a null ref on the calls to GroupRows, UngroupRows and GroupColumns.

Mishelle

Hi,

Well, for null ref Exception, Please change the code as (you need to instantiate the Worksheet object first before calling GroupColumns, UngroupRows, GroupRows etc.):

            _worksheet = _workbook.Worksheets[_workbook.Worksheets.AddCopy(0)];
//_worksheet.Cells.GroupColumns(4, 7);
//_worksheet.Cells.UngroupRows(8, 10);
//_worksheet.Cells.GroupRows( 8, 10);
Otherwise, the “_worksheet” object will be surely null.

And, we will look into the issue regarding grouping, and get back to you soon.

Thank you.

Hi,

"It now works correctly when the rows I’m sorting are part of a group,
but if I try to sort the entire group (Case 2 on my test sheet) I now
get a null ref exception"

We tried to find the issue but with no luck at all. Could you point out where is the problem, please provide us complete details. You may post the Aspose.Cells generated file using your code and also post the valid/desired file manually using MS Excel here. We will check it soon.

Thank you.


Yes, I see my mistake now. Thank you.

I was mistaken here as well. When I sort an entire group, it works. The null ref happens when I try to sort a range that includes a group plus additional rows. I’m not sure what the expected behaviour should be in that case, as even Excel gives inconsistent results. I can wrap it in a try/catch and ignore the null ref.

The issues you have found earlier (filed as 17907) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.