title: EPPlus Pivot Table - Collapse entire field
body: <p>Does anyone know how to do this?</p>
  
  <p>I'm using EPPlus in .Net and have created a pivot table with 2 row fields and one summary datafield:</p>
  
  <pre><code>Dim Pivot As OfficeOpenXml.Table.PivotTable.ExcelPivotTable
  Pivot = wksPivot.PivotTables.Add(wksPivot.Cells("A1"), Datarange, "pName")
  
  Pivot.RowFields.Add(Pivot.Fields("Fld1")).Sort = Table.PivotTable.eSortType.Ascending
  Pivot.RowFields.Add(Pivot.Fields("Fld2")).Sort = Table.PivotTable.eSortType.Ascending
  
  Dim dtaFld As OfficeOpenXml.Table.PivotTable.ExcelPivotTableDataField
  dtaFld = Pivot.DataFields.Add(Pivot.Fields("XYZ"))
  dtaFld.Function = Table.PivotTable.DataFieldFunctions.Sum
  </code></pre>
  
  <p>Everything works great, but I want to have the Pivot Table start off as collapsed when the user opens the workbook (In excel, when you're creating the pivot table, you can right-click in the data element and select "Expand / Collapse" > "Collapse Entire Field"</p>
  
  <p>Hot can I do this via code?? (And I'm willing to use direct OpenXML if EPPlus doesn't support this yet...)</p>
  
  <p><strong>ALSO</strong>, is there a way to delete out the Raw data from the workbook so that the pivot table still works? i've tried and when I open the workbook, my pivot table is blank? - My current logic has led me to <a href="https://stackoverflow.com/questions/16346004/openxml-epplus-create-pivotcache-in-net">this question</a>... Any thoughts??</p>
  
  <p>(I do know I wrote this question in VB. but I added both the <code>C#</code> &amp; <code>VB</code> tags to this question - I'm comfortable with code in either language - Thanks!!)</p>