title: ClosedXML and C#: How to collapse rows by Default?
body: <p>I am trying to write code which produces excel report with pivot table. For accomplishing this task I am using ClosedXML library. The output looks like this:
  <a href="https://i.stack.imgur.com/t3XxU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t3XxU.png" alt="ClosedXML produced excel worksheet with pivot table "></a></p>
  
  <p>The problem is that I have to get all groups of data collapsed by default, i.e. in the output I should see the following:
  <a href="https://i.stack.imgur.com/nEd6H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nEd6H.png" alt="Desired output - every row is collapsed."></a></p>
  
  <p>In other words, my output should contain collapsed rows and only summary should be displayed. How can I achieve this in code? Which method should I use? </p>
  
  <pre><code>        pt.ShowRowStripes = true;
          secondWorksheet.FirstRow().Hide();
          secondWorksheet.TabActive = true;
          secondWorksheet.CollapseRows(1);
          secondWorksheet.Rows().Collapse();
          pt.EnableShowDetails = false;
          pt.ShowValuesRow = false;
          secondWorksheet.PageSetup.ShowGridlines = true;
          secondWorksheet.ShowGridLines = true;
          workbook.PageOptions.ShowGridlines = true;
          secondWorksheet.PivotTables.First().EnableShowDetails = false;
  </code></pre>