gost-db-to-excel
v1.0.2
Published
export database data in excel format
Downloads
5
Maintainers
Readme
gost-file-manager
save db data in excel or excel in base64 format
Contact Developer on [email protected]/-7200066633.
Install npm package
npm install gost-db-to-excel
import {gostExcel} from 'gost-db-to-excel'
const querySql = 'SELECT * FROM user where userId < 100'
const sqlData = await query({ sql: querySql})
// Extract headers from the first object in the array
const headers = Object.keys(sqlData[0]);
// Extract data from the array of objects
const data = sqlData.map(obj => Object.values(obj));
var excelType = 'save' // returns output
// output
// Success: {success:true, status:200, Message:'Excel saved successfully'}
// Failed: {success:false, status:500, Message:Error Message}
var excelType = 'base64' // returns output
// output
// ({success:true, data:base64String});
// Generate Excel file
const base64Excel = gostExcel(headers, data, excelType, 'public/uploads/sample.xlsx');
Developer Contact gost at [email protected]{P}