## 5.5. Loading Excel (XLS)

This section describes procedures that can be used to import data from Excel files.

### 5.5.1. Library Requirements

For loading XLS we’re using the Apache POI library, which works well with old and new Excel formats, but is quite large. That’s why we decided not to include it into the apoc jar, but make it an optional dependency.

Please download these jars and put them into your `plugins` directory:

For XLS files:

- poi-3.17.jar

Additional for XLSX files:

- commons-collections4-4.1.jar
- poi-ooxml-3.17.jar
- poi-ooxml-schemas-3.17.jar
- xmlbeans-2.6.0.jar
- curvesapi-1.04.jar

### 5.5.2. Usage

The usage of `apoc.load.xls` is similar to `apoc.load.csv` with the main difference the ability to select a worksheet or a range from a sheet to load.

You can either select the sheet by name like `'Kids'`, or offset like `'Results!B2:F3'`

`CALL apoc.load.xls({url}, {Name of sheet}, {config})`

The `{config}` parameter is a map

name | description
--- | ---
`mapping` | `{mapping:{'<sheet>':{type:'<type>', dateFormat: '<format>', dateParse: [<formats>]}}}`
`<sheet>` | `name of the sheet`
`<type>` | `Default `String`, The type of the conversion requested (`STRING`, `INTEGER`, `FLOAT`, `BOOLEAN`, `NULL`, `LIST`, `DATE`, `DATE_TIME`, `LOCAL_DATE`, `LOCAL_DATE_TIME`, `LOCAL_TIME`, `TIME`)`
`dateFormat: <format>` | `Convert the Date into String (only String is allowed)`
`dateParse: [<formats>]` | `Convert the String into Date (Array of strings are allowed)`

#### 5.5.2.1. Note

In dateParse the first format matched return the date formatted, otherwise it will return an error

In `format` config you can use the pattern describe as the Temporal functions: temporal functions

### 5.5.3. Examples for `apoc.load.xls`

    CALL apoc.load.xls('file:///path/to/file.xls','Full',{mapping:{Integer:{type:'int'}, Array:{type:'int',array:true,arraySep:';'}}})

    CALL apoc.load.xls('http://bit.ly/2nXgHA2','Kids')

Some examples with type/dateFormat and dateParse:

    CALL apoc.load.xls('test_date.xlsx','sheet',{mapping:{Date:{type:'String'}}})

Figure 5.1. results

    CALL apoc.load.xls('test_date.xlsx','sheet',{mapping:{Date:{type:'String',dateFormat:'iso_date'}}})

Figure 5.2. results

    CALL apoc.load.xls('test_date.xlsx','sheet',{mapping:{Date:{type:'String',dateParse:["wrongPath", "dd-MM-yyyy", "dd/MM/yyyy", "yyyy/MM/dd", "yyyy/dd/MM", "yyyy-dd-MM'T'hh:mm:ss"]}}})

Figure 5.3. results