'Generate CSV file using name cell from JSON data in angular

The ask is to generate the csv file from JSON data in the format

jsonObj = {'key1' : 'value1',
           'key2' : 'value2',...}

I need to generate the CSV file using name cell format with 2 columns only

key1    value1
key2    value2
.       .
.       .
.       .

Including the concept of name cell where clicking on the cell 'value1' the cell is referred to as 'key1' instead of B1. I am using exportToCSV library in angular but could not find any. Code for Reference

` let csvData = [data.data];
    const options = {
      filename: "Q_String_" + primaryKey,
      fieldSeparator: ",",
      quoteStrings: '"',
      decimalSeparator: ".",
      showLabels: true,
      useTextFile: false,
      useBom: true,
      useKeysAsHeaders: true,
    };

    const csvExporter = new ExportToCsv(options);
    csvExporter.generateCsv(csvData);
    this.toastr.success("Q String has been downloaded","Success"); `

Any help would be appreciated?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source