Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
How to link html form to javascript function that appends row data into an excel file

I have written some code that appends row data into an excel worksheet using javascript and exceljs.

This file works perfectly fine independently without any HTML. However, my greater objective is to save form data into an excel file.

Here is the javascript code:

//Part1

const info = [];

function display(e){ 
    e.preventDefault();
    var nm = document.getElementById("nm").value;
    var ag = document.getElementById("ag").value;
    var data = [nm, ag];
    info.push(data);
    var text = document.createElement("h2"); 
    text.innerHTML = info;
    document.body.appendChild(text);
    console.log(info);

    // ----------------------------------------------

//Part2
    var Excel = require('exceljs');
    var workbook = new Excel.Workbook();
    workbook.xlsx.readFile("AppendRow.xlsx").then(function(){
        worksheet = workbook.getWorksheet("Main")
        worksheet.addRows(data);

    workbook.xlsx.writeFile("AppendRow.xlsx")
    });
}

In Part1, I am formatting the input details into a list so that I can easily append the data into excel....it puts all the user credentials into a list.

In Part2, it fetches the excel file and appends the data into a row (at least this is what I expect it to do, as I had mentioned it works fine independently but not when combined this way.)

Here is the HTML part:

<head>
    <h1 style="font-family: Broadway">HTML to Append Row Function :-)</h1>
</head>
<body>
    <script type="text/javascript" src="trial2.js"></script>
    <form method='POST' onsubmit = 'return(display())'>
        <input type="text" id='nm' placeholder="Name">
        <input type="number" id='ag' placeholder="Age">
        <input type="submit" value="Submit">
    </form>
</body>

On running the HTML file on the browser, I don't see any output. Nor do I see any new row appended into the excel file.

I assume the problem to be in linking the two files...so I copied the entire JavaScript code into the HTML script tag, but it still didn't work.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda