Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

390
Visualizações
How to get the Column Data of an Excel Sheet by Column header name in JavaScript?

I have an Excel sheet like this.

Name Email Phone Number Address
A abc 001 USA
B abf 002 CAN
C abe 003 CHI
D abd 004 UK

And a Dropdown list on an HTML page like this

  • Name
  • Email
  • Address

What I want when a user clicks on any of the items in the list box e.g on the Name Only The values from the name column should be fetched and converted into the JSON object.

I have tried this solution but I don't know how to specify the column name in the code.

  var selectedFile;
        document
            .getElementById("fileUpload")
            .addEventListener("change", function (event) {
                selectedFile = event.target.files[0];
            });
        document
            .getElementById("uploadExcel")
            .addEventListener("click", function () {
                if (selectedFile) {
                    var fileReader = new FileReader();
                    fileReader.onload = function (event) {
                        var data = event.target.result;

                        var workbook = XLSX.read(data, {
                            type: "binary"
                        });
                        workbook.SheetNames.forEach(sheet => {
                            let rowObject = XLSX.utils.sheet_to_row_object_array(
                                workbook.Sheets[sheet]
                            );

                            let jsonObject = JSON.stringify(rowObject);
                            document.getElementById("jsonData").innerHTML = jsonObject;
                            console.log(jsonObject);
                        });
                    };
                    fileReader.readAsBinaryString(selectedFile);
                }
            });

I am a newbie to javascript, so any help would be appreciated. Please only mention the javascript solutions. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda