Find the function - SaveTableToSpreadsheet - and a working example in the powerpack repository.

Here is an example of using the function in JavaScript:

SaveTableToSpreadsheet("MainContent_grdBooks", "Data.xlsx");

The same in RVL: