0

How to get the grouped row details in Office.JS excel add-in from the selected range.

Grouping

Any kind of help will much appreciated!

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Rajath
  • 2,611
  • 8
  • 27
  • 43

1 Answers1

1

[Update] This does not address the question, but there is a sample in Script Lab that demonstrates how to do that. Go to the Samples tab in Script Lab and search for "Outline".

Here is the code to group rows:

  Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getActiveWorksheet();

    // Group the larger, main level. Note that the outline controls
    // will be on row 10, meaning 4-9 will collapse and expand.
    sheet.getRange("4:9").group(Excel.GroupOption.byRows);

    // Group the smaller, sublevels. Note that the outline controls
    // will be on rows 6 and 9, meaning 4-5 and 7-8 will collapse and expand.
    sheet.getRange("4:5").group(Excel.GroupOption.byRows);
    sheet.getRange("7:8").group(Excel.GroupOption.byRows);
    await context.sync();
  });
  • @JakobNielsel-MSFT thanks for the response, My Question is different. I want to get the grouped rows information from the selected range. Ex If I select from A1:B17 I want to get 10:11, 13:15 is grouped.. – Rajath Oct 29 '22 at 04:49
  • Rajath, I am so sorry that I misread your question. I looked through the documentation for outlining and I was not able to find an API that can retrieve the information on how the rows or columns in a worksheet is grouped. Please consider posting a request in the https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/idb-p/Microsoft365DeveloperPlatform community that the API team can consider for the backlog. I recommend that you provide some additional detail on your scenario and the value the new API would have for you. – Jakob Nielsen-MSFT Oct 29 '22 at 23:01
  • Jakob, Thanks for the suggestion. I'll try to fine-tune the question – Rajath Oct 31 '22 at 15:24