Skip to content

Instantly share code, notes, and snippets.

View bharathirajatut's full-sized avatar

Bharathiraja bharathirajatut

View GitHub Profile
@bharathirajatut
bharathirajatut / gist:71bd3c715faa511a20c5433ae467cad3
Created April 15, 2017 06:50 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
<div>
<button class="centre btn mc" (click)="downloadExcel()">Download</button>
</div>
import { Workbook } from 'exceljs';
import * as fs from 'file-saver';
json_data=[{
"name": "Raja",
"age": 20
},
{
"name": "Mano",
"age": 40
},
{
"name": "Tom",
json_data=[{
"name": "Raja",
"age": 20
},
{
"name": "Mano",
"age": 40
},
{
"name": "Tom",
//create new excel work book
let workbook = new Workbook();
//add name to sheet
let worksheet = workbook.addWorksheet("Employee Data");
//add column name
let header=["Name","Age"]
let headerRow = worksheet.addRow(header);
for (let x1 of this.json_data)
{
let x2=Object.keys(x1);
let temp=[]
for(let y of x2)
{
temp.push(x1[y])
}
worksheet.addRow(temp)
}
//set downloadable file name
let fname="Emp Data Sep 2020"
//add data and file name and download
workbook.xlsx.writeBuffer().then((data) => {
let blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
fs.saveAs(blob, fname+'-'+new Date().valueOf()+'.xlsx');
});