how to show the ajax response(reports) in Excel format each object in each cell
-
Here i have working on download the reports in Excel and pdf format, i need to display the each object in each cell in excel.
code is :
<button onclick="printExcel()" style="width: 200px" class="small-button button loading-pulse lighten success">
Download Excel Report
</button><script>
function printExcel() {
console.log("jsreport.data--->",jsreport.data.posts);
var myJSON = JSON.stringify(jsreport.data.posts);
console.log("jsreport.myJSON-->",myJSON)
var blob = new Blob([myJSON], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"
});
saveAs(blob, "Report.xls");
}
</script>
-
the jsreport.data having the following data
{
"Facility": "PD Prototype Medical Center (Bridge)",
"Report_Type": "Discharge Medication Instructions",
"Time": "Jul 12, 2017 02:12AM",
"Name": "A,Yogesh Kannan,III",
"MRN": "4285",
"VN": "2643",
"DOB": "06/05/1993",
"Age": "24 years",
"Ht": "",
"Gender": "Male",
"Wt": "",
"BSA": "",
"Medication": "",
"FOod": " BSR",
"Sub": "",
"Latex": "",
"Discharge_Meds": [{
"Name": "Diflucan (Fluconazole)",
"Direction": "100 mg tab by mouth Wednesday, 7 December 2016",
"Next_Dose": "",
"Reason": "",
"Product": "Diflucan Oral Tablet 100 MG",
"Reason_Not_Continued": "",
"Comment": "",
"Quantity": "",
"Refills": "0",
"Status": "(Stop)"
},
{
"Name": "Aspirin",
"Direction": "",
"Next_Dose": "",
"Reason": "",
"Product": "Aspirin Powder",
"Reason_Not_Continued": "",
"Comment": "",
"Quantity": "1 capsule",
"Refills": "0",
"Status": "(Changed)"
},
{
"Name": "Aspirin",
"Direction": "1 mg by mouth three (3) times per day",
"Next_Dose": "",
"Reason": "",
"Product": "Aspirin Oral Tablet 325 MG",
"Reason_Not_Continued": "",
"Comment": "",
"Quantity": "0",
"Refills": "0",
"Status": "(Changed)"
},
{
"Name": "Ibuprofen",
"Direction": "200 mg by mouth three (3) times per day as needed",
"Next_Dose": "",
"Reason": "",
"Product": "",
"Reason_Not_Continued": "",
"Comment": "",
"Quantity": "0",
"Refills": "0",
"Status": "(Continued)"
},
{
"Name": "Glimepiride",
"Direction": "4 mg by mouth daily",
"Next_Dose": "",
"Reason": "",
"Product": "",
"Reason_Not_Continued": "",
"Comment": "",
"Quantity": "0",
"Refills": "0",
"Status": "(New)"
},
{
"Name": "Rx: Compazine (PO/IV/IM/PR) (Prochlorperazine (PO/IM/IV/PR))",
"Direction": "strength/unit ___ two (2) times per day",
"Next_Dose": "",
"Reason": "",
"Product": "",
"Reason_Not_Continued": "",
"Comment": "",
"Quantity": "0",
"Refills": "0",
"Status": "(New)"
}]
}
-
-
Am using third party API to get my reports in jsreport studio script section.
the code is :var http = require('http');
function beforeRender(req, res, done) {
require('request')({
url:"your_API",
json:true
}, function(err, response, body){
req.data.posts = body;
done();
});
}