Function Updated 23 Oct 2026
loadExcel(file, [startCol], [startRow], [sheetNo])
Loads data from Excel file into an array of objects.
Parameters
filestring (filepath)requiredAbsolute file path for Excel file (XLSX) to load data from.
startColnumberoptionalColumn number of the first header cell (counting from 1). The data rows are read from the same column, so the table can start anywhere on the sheet.
Default 1
startRownumberoptionalRow number of the header row (counting from 1). The data rows start on the row below it.
Default 1
sheetNonumberoptionalSheet number (counting from 1)
Default 1
Returns
An array of objects, one per row below the header row, down to the last used row of the sheet. The properties are named by the header cells, read from column to the right until the first empty header cell. All values are strings. If the file is not found, a string starting with "Load failed" is returned instead of an array.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
<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>The template above produces this output:
<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>