Load data from Excel (XLSX) Last updated: 20. Dec 2022
Example of how to load data from an Excel file and use it in your site.
LoadExcel(filename, column, row, sheet)
Loads data from excel file. First row must contain the headers.
Parameter | Type | Required | Description |
---|---|---|---|
filename | string (filepath) | yes | Absolute file path for Excel file (XLSX) to load data from. |
column | number | no | Column to start loading from (counting from 1) Default 1 |
row | number | no | Row to start loading data from (counting from 1) Default 1 |
sheet | number | no | Sheet number (counting from 1) Default 1 |
Example loading data to HTML-page
This example code loads data from an excel file:
<h1>Product list</h1>
<table>
<thead>
<tr>
<td>Number</td>
<td>Name</td>
<td>Price</td>
</tr>
</thead>
<tbody>
#var xlsx = docly.loadExcel("Test files/Example file.xlsx")#
#for(var row of xlsx) {#
<tr>
<td>#row.Number#</td>
<td>#row.Name#</td>
<td>#format(row.Price, "N")#</td>
</tr>
#}#
</tbody>
</table>
Contents of Excel (Example file.xlsx) file: