Updated May 2020
//XL, SetGroup, rowfirst=##, rowlast=## {,collapsed} {,summary {=#}}
This directive creates a row group that can be collapsed or expanded. If the collapsed argument is specified, the group will be initially collapsed when viewed in the spreadsheet application; else expanded. The summary option determines whether the spreadsheet app should allow for a summary line and where, above or below. Specifying the summary argument by itself, or summary=1, puts the summary below the group; summary=-1 puts it above. Note that you have to create the summary line yourself and insert it in the proper order. For example:
Conference,Team,Wins,Payroll($M)
AFC,Ravens,10,87
AFC,Patriots,10,79
AFC,Bills,9,82
//XL,SetGroup,rowfirst=2,rowlast=4,collapsed,summary
AFC,"",=SUM(C2:C4),=SUM(D2:D4)
NFC,49ers,10,93
NFC,Saints,8,75
NFC,Bears,7,74
//XL,SetGroup,rowfirst=6,rowlast=8,collapsed,summary
NFC,"",=SUM(C6:C8),=SUM(D6:D8)
In the above example we have column titles and two groups of three data rows with a summary line below it. Note that group has its own SetGroup directive below the data items, with the summary line below that. It would look like this in Excel:
(Collapsed)
(Expanded)
When the group summary line follows the data, the expand/contract buttons appear on the line above the group summary, which may seem a bit odd. The other option is to put the summaries above the data lines, which is more difficult to program (since you need to output the summary information before the details and thus can't calculate the summary while outputting the data), but may look cleaner in the resulting spreadsheet, particularly when collapsed:
Conference,Team,Wins,Payroll($M)
//XL,SetGroup,rowfirst=3,rowlast=5,collapsed,summary=-1
AFC,"",=SUM(C3:C5),=SUM(D3:D5)
AFC,Ravens,10,87
AFC,Patriots,10,79
AFC,Bills,9,82
//XL,SetGroup,rowfirst=7,rowlast=9,collapsed,summary=-1
NFC,"",=SUM(C7:C9),=SUM(D7:D9)
NFC,49ers,10,93
NFC,Saints,8,75
NFC,Bears,7,74
History
2019 December, CSV2XL.SBX edit 243, first included with A-Shell 6.5.1671: Add function to A-Shell