0

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?

Adnan Fayaz
  • 139
  • 2
  • 9
  • Can you post the code you tried and explain why it didn't work? – Nick.Mc Apr 18 '22 at 11:51
  • Ok @Nick.McDermaid – Adnan Fayaz Apr 18 '22 at 12:29
  • and why didn't it work? – Nick.Mc Apr 18 '22 at 12:32
  • @Nick.McDermaid. its generating two rows with key (first row) and value (second row) without naming cell references. I need it to get in two columns having a ability of naming a cell with their keys. For Ref, [link](https://www.techadvisory.org/2014/03/naming-cells-in-microsoft-office-excel/#:~:text=Each%20cell%20in%20the%20spreadsheet,next%20to%20the%20formula%20bar.) – Adnan Fayaz Apr 18 '22 at 12:38
  • Can you edit the question and add a sample of what it is producing? – Nick.Mc Apr 18 '22 at 12:45
  • Does this answer your question? [ANGULAR 5 : how to export data to csv file](https://stackoverflow.com/questions/51487689/angular-5-how-to-export-data-to-csv-file) – The Fabio Apr 18 '22 at 14:09
  • @TheFabio, No actually, i am in need to two columns with naming cells – Adnan Fayaz Apr 19 '22 at 05:28
  • I does allow you to get two cells (or any other subset...) look at this answer with care and I am sure you will figure it: https://stackoverflow.com/a/51488124/4604645 – The Fabio Apr 19 '22 at 05:30

0 Answers0