TXLSWorksheet.GroupRows does not work

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
ajoschi
Posts: 3
Joined: Wed Mar 13, 2013 8:16 am

TXLSWorksheet.GroupRows does not work

Post by ajoschi »

Hi.

I'm trying to group several rows in an Excel sheet I generated using XLSReadWriteII V5 (5.10.03).

I created a new sheet, generated some content in it and then used GroupRows(<minRow>, <maxRow>, True) to generate a colapsable/expandalbe group of rows.
It seems like this procedure does not do anything, since the exported sheet looks equal with or without calling this function (no row group was generated).

I then looked into the source and found the reason for this issue.
Reason seems to be the setter of the TXLSRow propery OutlineLevel:

Code: Select all

procedure TXLSRow.SetOutlineLevel(const Value: integer);
begin
  if FRowItem <> Nil then
    FRowItem.Height := Value
  else if Value <> 0 then begin
    FRowItem := FOwner.FCells.AddRow(FIndex,XLS_STYLE_DEFAULT_XF);
    FRowItem.OutlineLevel := Value;
  end;
end;
This code will not set/modify FRowItem.OutlineLevel in case it was already assigned before.

Changing the code to the following fixed this issue:

Code: Select all

procedure TXLSRow.SetOutlineLevel(const Value: integer);
begin
  if FRowItem <> Nil then
    FRowItem.Height := Value
  else
    FRowItem := FOwner.FCells.AddRow(FIndex,XLS_STYLE_DEFAULT_XF);
  if Value <> 0 then begin
    FRowItem.OutlineLevel := Value;
  end;
end;
With this code the row groups are generated correctly.

I'm not sure if this modification may have any negative side effects, so here my questions:
1. From our view: Could this modification cause any side effects?
2. Will you apply this (or any other kind of) fix in the next version?

Another issue is, that when I pass True for parameter ACollapsed (TXLSWorksheet.GroupRows) it does not seem to have any effect.
The row group is still expanded.
Is this a known issue?

Thanks in advance and best regards!
Ajoschi
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: TXLSWorksheet.GroupRows does not work

Post by larsa »

Hello

This is fixed in update 5.10.05

When setting collapsed outline manually, you must also set the collapsed rows to hidden. Example:

Code: Select all

  XLS[0].Rows[2].OutlineLevel := 1;
  XLS[0].Rows[3].OutlineLevel := 1;
// A second level.
  XLS[0].Rows[4].OutlineLevel := 2;
  XLS[0].Rows[5].OutlineLevel := 2;
  XLS[0].Rows[6].OutlineLevel := 2;
  XLS[0].Rows[7].OutlineLevel := 1;

// Collapse (hide) the second level.
  XLS[0].Rows[4].Hidden := True;
  XLS[0].Rows[5].Hidden := True;
  XLS[0].Rows[6].Hidden := True;
// Set the last row in the group to CollapsedOutline. This is where the +/- button will be.
  XLS[0].Rows[7].CollapsedOutline := True;
Lars Arvidsson, Axolot Data
ajoschi
Posts: 3
Joined: Wed Mar 13, 2013 8:16 am

Re: TXLSWorksheet.GroupRows does not work

Post by ajoschi »

Hello

Ok, thanks for the fix this works for XLSX files.

I notice now with V5.10.05 that the grouping of rows is not shown for XLS files, only for XLSX (when I open them in Excel).
In opposite to this, when I use Excel to manually generate some row groups, after saving and reopen, the grouping is visible.
Is this a bug?
Can I configure this somewhere in the generated excel export?

best regards,
ajoschi
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: TXLSWorksheet.GroupRows does not work

Post by larsa »

Hello

Grouping rows and cols in Excel 97 files is fixed in update 5.10.07
Lars Arvidsson, Axolot Data
ajoschi
Posts: 3
Joined: Wed Mar 13, 2013 8:16 am

Re: TXLSWorksheet.GroupRows does not work

Post by ajoschi »

Hi.

I just want to confirm that this works now with 5.10.07.
Thanks!
Post Reply