title: getPivotCacheDefinition return null value when Refresh Pivot Table with Apache POI
body: <p>I want to refresh pivot table after enter data to data sheet </p>
  
  <p>I read two previous questions [this][1] and [this][2]. there two way to do this</p>
  
  <p>one way is</p>
  
  <p>Right click your pivot table -> pivotTable Options -> Data -> Check Refresh Data when opening File</p>
  
  <p>this is working I want a automated way so I tried in this way</p>
  
  <pre><code>FileInputStream inputStream = new FileInputStream(new File(excelFilePath));
  workbook = new XSSFWorkbook(inputStream);
  XSSFSheet sheet = workbook.getSheet("Summary");
  XSSFPivotTable pivotTable = sheet.getPivotTables().get(0);
  pivotTable.getPivotCacheDefinition().getCTPivotCacheDefinition().setRefreshOnLoad(true);
  </code></pre>
  
  <p>I have two pivot tables in this sheet so <code>sheet.getPrivotTable</code> return this </p>
  
  <pre><code>[Name: /xl/pivotTables/pivotTable1.xml - Content Type: application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml, Name: /xl/pivotTables/pivotTable2.xml - Content Type: application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml]
  </code></pre>
  
  <p>but <code>sheet.getPivotTables().get(0).getPivotCacheDefinition()</code> return null value.</p>
  
  <p>Is there any way to refresh Pivot table automatically? </p>