How to get Excel sheet names?
14:10 10 Jun 2019

I am trying to get the list of the sheets from an excel file in order to display it in a combobox. The idea is that the user can select the file that he want to import from an excel file instead of typing and avoid typo errors

function getSheets(file)
{
    var reader;
    reader = new FileReader();
    reader.onload = function(e)
    {
        var data;
        var workbook;
        var sheets;
        data = e.target.result();
        workbook = XLSX.read(data, {type: 'binary'});
        sheet = workbook.SheetNames;
        for (var i in sheets.items)
        {
            console.log(sheets.items[i].name);
        }
    }
    reader.onerror = function(ex)
    {
        console.log(ex);
    }
    reader.readAsBinaryString(file);
}

The following error is displayed when the function is executed: Function expected on line: data = e.target.result(); Any idea of how should I face it?

javascript