LoadExcel(filename, [column], [row], [sheet]) Last updated: 16. May 2023

Loads data from Excel file into an array of objects.

Parameters

Name Type Description
filename string (filepath) Absolute file path for Excel file (XLSX) to load data from.
column (optional) number Column number to start reading from (counting from 1)
Default 1
row (optional) number Row number to start reading from (counting from 1)
Default 1
sheet (optional) number Sheet number (counting from 1)
Default 1

Returns

An array of objects. Each object representing one row in the Excel file with properties named by the column names with the cell values.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
<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>

Output

The #JS code above produces the output shown below:
<h1>Product list</h1>
<table>
    <thead>
    <tr>
        <td>Number</td>
        <td>Name</td>
        <td>Price</td>
    </tr>
    </thead>
    <tbody>
     <tr>
        <td>1</td>
        <td>Product A</td>
        <td></td>
    </tr>
    <tr>
        <td>2</td>
        <td>Product B</td>
        <td></td>
    </tr>
    <tr>
        <td>3</td>
        <td>Product C</td>
        <td></td>
    </tr>
</tbody>
</table>