Current filter:
                                You should refresh the page.

                                1 Solution

                                Creation Date Importance Sort by

                                Updated

                                Our SpreadsheetControl does not provide a public API to collapse/expand certain rows in a worksheet. At the moment, only rows with a certain grouping level can be collapsed/expanded using the Rows.CollapseGroups(Int32) method.

                                As a workaround, you can use ShowDetailCommand and HideDetailCommand commands to expand/collapse grouped rows. These commands expand and collapse rows and columns based on the current selection in a worksheet. So, it is necessary to select the required grouped rows before executing the command.
                                See the code below for clarification:

                                [C#]
                                void ExpandGroupRow(Range expandedRange) { spreadsheetControl1.BeginUpdate(); Range selectedRange = spreadsheetControl1.Selection; spreadsheetControl1.Selection = expandedRange; ExpandGroups(); spreadsheetControl1.Selection = selectedRange; spreadsheetControl1.EndUpdate(); } void ExpandGroups() { SpreadsheetCommand command = spreadsheetControl1.CreateCommand(SpreadsheetCommandId.ShowDetail); command.Execute(); } //usage ExpandGroupRow(b8Range); ExpandGroupRow(b13Range);
                                Show all comments
                                • K_P 08.16.2019

                                  Thanks for the above solution....

                                  I have excel sheet contains grouped element and initially all in collapsed state. now I want to pass the row numbers and only those rows should be expanded. 

                                • K_P 08.16.2019

                                  I have gone through the solution. In my case, at run time I will come to know which groups should be expanded.

                                  In provided solution range is selected from 1st group to 2 group but group can be dynamic. lets say in attached excel screen shot group no 6th and 9th should be expanded and rest should be in collapsed state.  

                                • Yulia (DevExpress Support) 08.19.2019

                                  Thank you for your clarification. You can use ShowDetailCommand to expand a certain group row. Select a row you need to expand and execute ShowDetailCommand for the selection. Repeat this action for each row that should be expanded.
                                  See the code below for clarification:

                                  [C#]
                                  void ExpandGroupRow(Range expandedRange) { spreadsheetControl1.BeginUpdate(); Range selectedRange = spreadsheetControl1.Selection; spreadsheetControl1.Selection = expandedRange; ExpandGroups(); spreadsheetControl1.Selection = selectedRange; spreadsheetControl1.EndUpdate(); } void ExpandGroups() { SpreadsheetCommand command = spreadsheetControl1.CreateCommand(SpreadsheetCommandId.ShowDetail); command.Execute(); } //usage ExpandGroupRow(b8Range); ExpandGroupRow(b13Range);
                                • K_P 08.19.2019

                                  Thank you...

                                • Yulia (DevExpress Support) 08.19.2019

                                  You are welcome.

                                • K_P 08.19.2019

                                  I have used below function. 3rd parameter will take of collapse and expand mode for group.

                                  worksheet.Rows.Group(startGroupRowIndex , endGroupRowIndex, collapsed)

                                • Yulia (DevExpress Support) 08.19.2019

                                  Thank you for informing us that the task has been solved and for sharing your solution. Please do not hesitate to contact us in case of any difficulty. We will be happy to help you!