HTML Form inputs stored inputs data to Excel sheet

Continuing the discussion from Form To Excel Sheet:

Please I am seeking for help on how to store my HTML form inputs to excel sheet or excel database.

Hello and welcome to the forum :slight_smile:!

On the link you reference is a response to what you’re asking, what’s the problem you’re currently having? Are there any errors?

Otherwise I’d point you to, for example, this Excel JavaScript library, which will help you parse and generate the books.

I didn’t even no steps to take but I do know how to design form input but the of excel I do not know where to start on how to connect my form to excel sheet.

Oh, OK.

In that case, you should start by learning JavaScript and HTML, otherwise you won’t get far.

You should start with:

That should give you the basics to create what you need :slight_smile:.

Alright but why do I need Javascript?

Good question!

It depends. I assumed (shame on me :sweat_smile:) you wanted to create the excel book directly on the browser, in which case you have no other option than to learn JavaScript.

Now, if you want to send the data to the server and there create the book, then it will depend on your server side language.

The only common part is that you would need a library that reads/writes the excel books and, with it, create the books.

You cannot (AFAIK) create an excel book directly from the inputs on your form.

How will I do that with Javascript ? Please can you help me with an example of what you said.

JavaScript is what makes websites do things. If you want an interactive website, then you need to learn JavaScript.

Are you trying to say that is in JavaScript that I will put the code that store input data to excel sheet?

JavaScript is the language you will write your code in.

Are you trying to say that is in JavaScript that I will put the instruction code that store input data to excel sheet?

OK. I got it now. Thanks a lot.

Please want to know if I should created my excel database first? How should I save my excel sheet? And also should I create excel folder in same folder with HTML and CSS?.

Honestly, if you want to build this yourself from scratch, you’re going to need to spend a long time learning the fundamentals of web programming first.

Am using Bracket file to program.

Ok.

Sure, but if you don’t know JavaScript you may not be able to understand it.

Here it is, a simple example using SheetJS to create a simple book from two inputs:

<label>Name: <input type="text" id="name" value="John" /></label><br />
<label>Last Name: <input type="text" id="lastName" value="Doe" /></label><br />
<button id="saveBook" type="button">
  Save
</button>
function saveBook() {
  const name = document.getElementById('name').value;
  const lastName = document.getElementById('lastName').value;

  if (!name || !lastName) {
    return;
  }
  
  // A multidimensional array represents the data.
  // Each array is a new row and each item on the
  // array is a different column (cell).
  const data = [
    // A     B
    ["Name", "Last Name"], // Row 1
    [name, lastName] // Row 2
    // Row N
  ];

  // Creates the sheet data
  const ws = XLSX.utils.aoa_to_sheet(data);
  // Create a new book where to append the data.
  const wb = XLSX.utils.book_new();
  
  // Append the sheet (second param) to the book (first param)
  // with the specified name (third param)
  XLSX.utils.book_append_sheet(wb, ws, "Test Sheet");
  
  // This is the instruction that tells the browser to
  // "download" the file
  XLSX.writeFile(wb, 'book.xlsx');
}

document.querySelector('#saveBook').onclick = saveBook;

Thanks but what will I save my excel sheet with? I mean file name.

That’s up to you. You haven’t specified any kind of context or what you’re trying to achieve.

If the example I gave is enough, then the name is not important. When the browser asks to save the file, it will use book.xlsx (in the sample).

Alright. I just want to design a website and it will be containing registration from and I want to be able to see names of those that have registered and to see the names of those people I have to create a database where their names will store. I just need the HTML form code link to excel database.