JSFiddle - React, Tailwind, and code Playground

HTML

<button onclick="exportToCsv()">export to CSV</button>

JavaScript

var Results = [
  ["Col1", "Col2", "Col3", "Col4"],
  ["Data", 50, 100, 500],
  ["Data", -100, 20, 100],
];

exportToCsv = function() {
  var CsvString = "";
  Results.forEach(function(RowItem, RowIndex) {
    RowItem.forEach(function(ColItem, ColIndex) {
      CsvString += ColItem + ',';
    });
    CsvString += "\r\n";
  });
  window.open('data:application/vnd.ms-excel,' + encodeURIComponent(CsvString));
}