0
I found a script to integrate Firestore with Google Sheets, but when running it, the columns are in order with each data update. How can I fix this?
https://i.imgur.com/Ski4t8q.png
A detail: I have more columns than those shown in the print (just to understand)
function getFirestore(){
return FirestoreApp.getFirestore(email, key, projectId);
}
function importFromFirestore(){
const firestore = getFirestore();
const allDocuments = firestore.getDocuments('Visita').map(function(document){
return document.obj;
});
const first = allDocuments[0];
const columns = Object.keys(first);
const sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(columns);
allDocuments.forEach(function(document){
const row = columns.map(function(columns){
return document[columns];
});
sheet.appendRow(row);
});
It helped a lot. It worked. Thank you very much.
– Thiago