Read Data From Excel

IS it this?

var workbook = XLSX.readFile('test.xlsx');

Good one.

That line turns the excel file in to a workbook object, that you can then work with from within JavaScript.

The Working with the Workbook section has details on doing stuff with the workbook, including accessing a sheet and then cells from that sheet.

1 Like

Wow I could not believe i would get this far. Thank you so much ffor your time and help.

2 Likes

Where do i place this code:

var workbook = XLSX.readFile('test.xlsx');

That is the first line of JavaScript, which is normally placed in a script tag at the end of the body, just before the </body> tag.

How am i doing?

<!DOCTYPE html>
<Html>
<Head>
<script lang="javascript" src="dist/xlsx.core.min.js"></script>  
</head>

<body>
<script>
var workbook = XLSX.readFile('test.xlsx');

</script>

  
</body>










</html>

You’re doing well.

Can you help me a bit on this part?

You may need to give me some context on what you mean by “this part”.
Otherwise, my answer will be Yes I can.

I mean can you add some code that will display the first column and row at any day and time?

You are the one that is writing code today, I am not writing code today.

So to carry on with my helping you, the first example of the Working with the worksheet documentation shows you how to access the A1 cell.

1 Like

Nothing shows up in the browser!

<!DOCTYPE html>
<Html>
<Head>
<script lang="javascript" src="dist/xlsx.core.min.js"></script>
</head>

<body>
<script>
var workbook = XLSX.readFile('test.xlsx');
var first_sheet_name = workbook.SheetNames[0];
var address_of_cell = 'A1';

/* Get worksheet */
var worksheet = workbook.Sheets[first_sheet_name];

/* Find desired cell */
var desired_cell = worksheet[address_of_cell];

/* Get the value */
var desired_value = (desired_cell ? desired_cell.v : undefined);
</script>


</body>

That’s because you haven’t told it to.

The value of the A1 cell is stored in the variable called desired_value. You can use that variable which contains the cell value in any way you wish.

I don’t get you here. What should i do?

That all depends on what it is that you want to do. What do you want to do?

I want to display the information in cell A1

In which HTML element do you want to display the information?

In side the body

Do you know how to show information inside of the body?

Nooo Im not sure how to do this