# GrapeCity.Documents.Excel.IPivotTable.ClearTable

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Excel_IPivotTable_ClearTable_" data-uid="GrapeCity.Documents.Excel.IPivotTable.ClearTable*">ClearTable Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Excel_IPivotTable_ClearTable_" data-uid="GrapeCity.Documents.Excel.IPivotTable.ClearTable*"></a>
<h4 id="GrapeCity_Documents_Excel_IPivotTable_ClearTable" data-uid="GrapeCity.Documents.Excel.IPivotTable.ClearTable">ClearTable()</h4>
<div class="markdown level1 summary"><p>Clears the PivotTable.</p>
<p>
Clearing a PivotTable removes all fields and deletes any filtering and sorting
applied to the report. This method resets the PivotTable to the state it had
immediately after creation, before any fields were added.
</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">void ClearTable()</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Sub ClearTable()</code></pre>
</div>
<h5 id="GrapeCity_Documents_Excel_IPivotTable_ClearTable_examples">Examples</h5>
<pre><code class="lang-csharp">object[,] sourceData = {
    {"Product", "Region", "Amount"},
    {"Apple", "East", 120},
    {"Pear", "West", 80}
};
worksheet.Range["A1:C3"].Value = sourceData;
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C3"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "PivotTable1");
pivotTable.PivotFields["Region"].Orientation = PivotFieldOrientation.RowField;
pivotTable.AddDataField(pivotTable.PivotFields["Amount"], "Sum of Amount", ConsolidationFunction.Sum);
pivotTable.ClearTable();</code></pre>

</div>
