How to find grouped rows and columns

Hello,

I see in your documentation that I can add groupings using the GroupRows and GroupColumns methods, and I can remove groupings using UngroupRows and UngroupColumns. Is there a way for me to tell whether there are groupings and which rows/columns are grouped?

Thank you,

Mishelle

Hi Mishelle,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am afraid your requested feature is not support with Aspose.Cells at the moment. We have added your feature request into our internal issue tracking system with issue id: CELLSNET-17656. We will look into it and get back to you soon.

Thank You & Best Regards,

Hi,

Please try the attached version.

We have supported Row.GroupLevel and Column.GroupLevel API, If they are not zero , it means they are grouped.


Thank you.

Thanks, I will try it.

Will I be able to tell from the numbers which rows are grouped with other rows? For example if I wanted to remove the groupings temporarily then add them back, how can I tell where I need to add them back? I was hoping for a collection of groups (or one for row groups and one for column groups) that I could iterate through.

Mishelle

Hi,

We cannot not gather the grouped information into a simple ArrayList.
Please try the following sample codes, you will get the grouped information in the MyGroup.Groups.

internal class MyGroup
{
internal MyGroup()
{
this.Groups = new ArrayList();
}
internal int Level;
internal int StartRow;
internal int EndRow;
internal ArrayList Groups;
}
static void Main(string[] args)
{

Workbook book = new Workbook();
book.Open(@"F:\FileTemp\Book1.xls");
Stack stack = new Stack();

Row preRow = null;

MyGroup preGroup = null;
MyGroup group = new MyGroup();
// stack.Push(group);
for (IEnumerator ie = book.Worksheets[0].Cells.GetRowEnumerator(); ie.MoveNext(); )
{
Row row = (Row)ie.Current;
if (preRow == null || preRow.Index + 1 != row.Index
|| row.GroupLevel == 0)
{
preRow = row;
//pop up all stack.
while (stack.Count != 0)
group =(MyGroup)stack.Pop();
if (row.GroupLevel != 0)
{
stack.Push(group);
preGroup = group;
group = new MyGroup();
group.Level = row.GroupLevel;
group.StartRow = row.Index;
preGroup.Groups.Add(group);
}
continue;
}

if (preRow.GroupLevel == row.GroupLevel)
{
group.EndRow = row.Index;
}
else if (preRow.GroupLevel > row.GroupLevel)
{
//pop up the stack until the grouplevel is same as the current row.
while (true)
{
group = (MyGroup)stack.Pop();
if (group.Level == row.GroupLevel)
{
group.EndRow = row.Index;
break;
}
}

}
else
{
stack.Push(group);
preGroup = group;
group = new MyGroup();
group.Level = row.GroupLevel;
group.StartRow = row.Index;
preGroup.Groups.Add(group);
}
preRow = row;
}
if (stack.Count != 0)
group = (MyGroup)stack.Pop();
book.Save(@"F:\FileTemp\dest.xls");



}


Thank you.

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


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