This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array = [1, [2, [3]], 4, []]; | |
const flatter = (array) => { | |
let flatArray = []; | |
array.forEach((item, index) => { | |
if (Array.isArray(item)) { | |
flatArray = flatArray.concat(flatter(array[index])); | |
} else { | |
flatArray.push(item); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jsPDF from 'jspdf'; | |
import 'jspdf-autotable'; | |
import moment from 'moment'; | |
const generateTableReport = (data) => { | |
// assuming your data is an array, inside an object | |
const { entries } = data; | |
const report = jsPDF(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlsx from 'xlsx'; | |
const generateSpreadsheet = (data) => { | |
const data = xlsx.utils.json_to_sheet(data); | |
const workBook = xlsx.utils.book_new(); | |
xlsx.utils.book_append_sheet(workBook, data, 'example spreadsheet'); | |
xlsx.writeFile(workBook, 'example spreadsheet.xlsx'); | |
}; |