-2

How to export json formatted data to excel.please help me.My json data si given below:

{"CreditorIncome":[],"totalCrediorIncome":0,"CreditorExp":[{"creditor_fname":"aaaa","income_expense":"Expense","amount":"1400.59","payment_mode":"Debtor"}}],
"totalCreditorExp":"86530.43","StaffCredit":[{"creditor_fname":"bbbb","income_expense":"Expense","amount":"150","payment_mode":"Debtor"},
"totalStaffCredit":"900","MiscExp":[{"employee_name":"cccc","income_expense":"Expense","amount":"345.14","payment_mode":"miscellaneous","remarks":"dg hsd"}]
,"totalMiscExp":"202468.14","MiscIncm":[{"employee_name":"dddd","income_expense":"Income","amount":"450","payment_mode":"miscellaneous","remarks":"air"},
{"employee_name":"eee","income_expense":"Income","amount":"850","payment_mode":"miscellaneous","remarks":"oil cash"}],
"totalMiscIncm":"1300","CardIncm":[{"income_expense":"Income","amount":"500","payment_mode":"Credit\/Debit Card"}],"totalCardIncm":"500",
"CardExp":[{"income_expense":"Expense","amount":"78280.15999999999","payment_mode":"BPCL Petrol card"},
{"income_expense":"Expense","amount":"307270.87999999995","payment_mode":"Credit\/Debit Card"}],
"totalCardExp":"385551.04","Cheque":[{"income_expense":null,"amount":null,"payment_mode":null}],
"CashSales":[{"amount":"343205","payment_mode":"Cash"}],"cash_income":[{"employee_name":"ffff",
"income_expense":"Income","amount":"21825","payment_mode":"Cash","remarks":""},
"cash_expense":[],"cash_total_income":"343205","cash_total_expense":0,"Chequetotal_income":0,"Chequetotal_expense":0,
"Cheque_Income":[],"Cheque_expense":[],"Received":[],"ReceivedTot":0,
"Banktransctn":[{"creditor_fname":"gggg","income_expense":"Income","amount":"184848","payment_mode":"Bank Transfer","remarks":"fund transfer"}],
"TotalbanktransctnAmt":"184848","mpdsales":"1020504.92","totalexpence":675449.61,"totalincome":1021804.92}
Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215
Athira
  • 11
  • 1
  • 5

2 Answers2

0

I think you should try this reference

https://github.com/trantrunghieu0809/json-export-excel

Tanjeeb Ahsan
  • 87
  • 1
  • 7
0
  1. Go to this https://www.npmjs.com/package/angular2-csv.
  2. Install this by typing "npm install --save angular2-csv" in the cmd
  3. import { Angular2Csv } from 'angular2-csv/Angular2-csv' in your "ts" file.
  4. In your "html" file use this <button (click)="exporttoExcel()">Export To Excel</button>
  5. Create below function in your ".ts" file.

    function exporttoExcel () {
       new Angular2Csv(this.form.controls.rows.value, 'Print List', { headers: Object.keys(this.form.controls.rows.value[0])});
    }
    
Apurv Chaudhary
  • 1,672
  • 3
  • 30
  • 55
Joseph
  • 7,042
  • 23
  • 83
  • 181