Fails to export the chart or pivot data and throws "argument is of length zero" error

If you get an error like following when you export the chart or pivot table data to Excel, CSV or Clipboard, you can try to close and reopen the project and try it again. In most of the cases, it solves the problem.

Error in if (viz_cache_env$type == "pivot") { : 
  argument is of length zero