const admin = require('firebase-admin');
const fs = require('fs');
const XLSX = require('xlsx');
admin.initializeApp({
credential: admin.credential.cert(serviceAccountKey),
databaseURL: 'https://YOUR_PROJECT_ID.firebaseio.com'
});
const dbRef = admin.database().ref('/path/to/database');
dbRef.once('value')
.then((snapshot) => {
const data = snapshot.val();
const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.json_to_sheet(data);
XLSX.utils.book_append_sheet(workbook, worksheet, 'Data');
const excelFilePath = '/path/to/save/excel/file.xlsx';
XLSX.writeFile(workbook, excelFilePath);
console.log('Firebase database exported to Excel successfully.');
})
.catch((error) => {
console.error('Error exporting Firebase database to Excel:', error);
});