title: Update PivotTable DataSource with the Office Excel JavaScript API
body: <p>I want to use the Excel JavaScript API to update an existing <code>PivotTable</code>'s data source, which will be a range in another sheet in the same workbook as the pivot table.  I've only found documentation that shows how to define a <code>PivotTable</code>'s data source when <a href="https://docs.microsoft.com/en-us/javascript/api/excel/excel.pivottable?view=excel-js-preview#excel-excel-pivottable-getdatasourcestring-member(1)" rel="nofollow noreferrer">creating</a> a new pivot table, not changing an existing <code>PivotTable</code>'s data source.</p>
  <p>It was possible to change an existing pivot table's data source when developing an Excel COM <a href="https://stackoverflow.com/a/9764063/4664207">add-in</a> and when using <a href="https://answers.microsoft.com/en-us/msoffice/forum/all/change-pivot-table-data-source-through-vba/073b0e3b-1a9c-4d7d-bdfc-fc892040f7b6" rel="nofollow noreferrer">VBA</a>, so I'm surprised to not see an example of it in the JavaScript API documentation so far.</p>
  <p>Does anyone know how to update a <strong>existing</strong> <code>PivotTable</code>'s data source using the Excel JavaScript API?</p>