How to custom csv export?

Hi, I’m trying to set up a csv export, with the correct locale and encoding (FR), but when I’m running the custom JS, I’m getting “Nothing to export”, whereas my collection containes rows (see pic below). I tried to write the name of the collectoin again, but still the same issue.


Here is the custom js i’m running :

function formatNumberFR(value) {
return typeof value === ‘number’
? value.toLocaleString(‘fr-FR’, { minimumFractionDigits: 2 })
: value;
}

function exportCSVFromWeWeb(collectionName, filename = ‘export.csv’) {
const data = wwLib.wwVariable.getValue(collectionName);

if (!data || !Array.isArray(data) || data.length === 0) {
    alert("Aucune donnée à exporter.");
    return;
}

// En-têtes
const headers = Object.keys(data[0]);

// Lignes de données formatées
const rows = data.map(row =>
    headers.map(key => {
        const value = row[key];
        return `"${formatNumberFR(value)}"`; // ajoute des guillemets pour gérer les virgules
    }).join(';')
);

// Contenu CSV avec BOM
const csvContent = '\uFEFF' + [
    headers.join(';'),
    ...rows
].join('\n');

const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });

// Créer un lien de téléchargement
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);

}

// Remplacer par le nom réel de ta collection
exportCSVFromWeWeb(‘CAs_paginated_groupe’, ‘donnees-exportees.csv’);

Any hints to resolve this issue ?

Thanks