XL.LoadBook
-----------

Loads a Excel file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XL](component_XL.md) | [2.9](newinversion29.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XL.LoadBook"; Data { ; Type; Password } ) 

**MBS**( **"XL.LoadBook";** /\* Loads a Excel file. \*/  
**$Data**; /\* Either text with file path or container value which contains the Excel file data.e.g. "C:\\test\\test.xls" \*/   
**$Type**; /\* Optional; Which type of file this is.   
Pass 0 for unknown, 1 to try xml format (xlsx) and 2 to try binary format (xls).  
Default is 0 to detect automatically.e.g. 0 \*/   
**$Password**) /\* Optional; Optional password for reading password protected files.  
Requires LibXL 5.0.e.g. "secure password" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Data | Either text with file path or container value which contains the Excel file data. | "C:\\test\\test.xls" |  |
| Type | Which type of file this is.    Pass 0 for unknown, 1 to try xml format (xlsx) and 2 to try binary format (xls).   Default is 0 to detect automatically. | 0 | Optional |
| Password | Optional password for reading password protected files.   Requires LibXL 5.0. | "secure password" | Optional      Added in version **16.0**. |

### Result

Returns book reference number on success or error.

### Description

Loads a Excel file.   
Works with both XML based xlsx files and older xls files.  
Book reference numbers are starting at 19000 and counting up for each new book.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Load file from container with auto detect:

 Set Variable \[ $book ; Value: MBS ( "XL.LoadBook"; MyTable::myFileContainer ; 0 ) \]  
Preprocess file before import in FileMaker by removing a row and a sheet:

 # Find libXL and load it   
If \[ MBS ("[XL.IsInitialized](XLIsInitialized.md)") ≠ 1 \]   
 Perform Script \[ Specified: From list ; “InitXL” ; Parameter: \]  
End If  
\#   
\# path to xls or xlsx file   
Set Variable \[ $path ; Value: MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ); "test.xls" ) \]   
\#   
\# Load template excel file   
Set Variable \[ $bookRef ; Value: MBS ( "XL.LoadBook"; $path ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Error" ; $bookRef \]   
 Exit Script \[ Text Result: \]   
End If  
\#   
\# Remove first row of first sheet   
Set Variable \[ $r ; Value: MBS ( "[XL.Sheet.RemoveRow](XLSheetRemoveRow.md)"; $BookRef ; 0 /\* sheet index \*/; 0 /\* row index \*/) \]   
\#   
\# Remove second sheet   
Set Variable \[ $r ; Value: MBS ( "[XL.Book.DeleteSheet](XLBookDeleteSheet.md)"; $bookRef ; 1 /\* sheet index \*/ ) \]   
\#   
\# Save to file and cleanup   
Set Field \[ XL::OutputFile ; MBS ("[XL.Book.SaveToFile](XLBookSaveToFile.md)"; $bookRef ; $path ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Book.Release](XLBookRelease.md)"; $bookRef ) \]   
\#   
\# now let FileMaker import file   
### See also

- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [XL.Book.DeleteSheet](XLBookDeleteSheet.md)
- [XL.Book.Release](XLBookRelease.md)
- [XL.Book.Save](XLBookSave.md)
- [XL.Book.SaveToFile](XLBookSaveToFile.md)
- [XL.CopyCellValue](XLCopyCellValue.md)
- [XL.IsInitialized](XLIsInitialized.md)
- [XL.LoadBookPartially](XLLoadBookPartially.md)
- [XL.Sheet.CellWriteFormula](XLSheetCellWriteFormula.md)
- [XL.Sheet.CellWriteText](XLSheetCellWriteText.md)

### Release notes

- **Version 16.1**
    - Added [XL.LoadBookInfo](https://www.mbsplugins.eu/XLLoadBookInfo.shtml) function.
- **Version 16.0**
    - Added password parameter for [XL.LoadBook](https://www.mbsplugins.eu/XLLoadBook.shtml) and [XL.LoadBookPartially](https://www.mbsplugins.eu/XLLoadBookPartially.shtml) functions.
- **Version 14.3**
    - Fixed a memory leak in loading Excel file from disk with [XL.LoadBook](https://www.mbsplugins.eu/XLLoadBook.shtml) function.
- **Version 14.2**
    - Added keepAllSheets parameter for [XL.LoadBookPartially](https://www.mbsplugins.eu/XLLoadBookPartially.shtml) function.
- **Version 8.0**
    - Added better error message when calling [XL.LoadBook](http://www.mbsplugins.eu/XLLoadBook.shtml) or [XL.NewBook](http://www.mbsplugins.eu/XLNewBook.shtml) without calling [XL.Initialize](http://www.mbsplugins.eu/XLInitialize.shtml).
    - Added [XL.LoadBookPartially](http://www.mbsplugins.eu/XLLoadBookPartially.shtml) function.

### Example Databases

- [XL/Change Column Names](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Change%20Column%20Names.shtml#4ScriptAnchor_)
- [XL/Converter](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Converter.shtml#1ScriptAnchor_)
- [XL/Edit Sheet](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Edit%20Sheet.shtml#1ScriptAnchor_)
- [XL/XL Import and Export](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/XL%20Import%20and%20Export.shtml#5ScriptAnchor_)
- [XL/XL Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/XL%20Test.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin 16.0 News](https://www.mbsplugins.de/archive/2026-01-20/MBS_FileMaker_Plugin_160_News/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.6pr4](https://www.mbsplugins.de/archive/2025-12-22/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.3pr1](https://www.mbsplugins.de/archive/2024-06-03/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 13 - XL](https://www.mbsplugins.de/archive/2023-12-13/MBS_Plugin_Advent_calendar_13_/monkeybreadsoftware_blog_filemaker)
- [Tips and tricks with MBS](https://www.mbsplugins.de/archive/2023-08-10/Tips_and_tricks_with_MBS/monkeybreadsoftware_blog_filemaker)
- [New column names in an Excel document](https://www.mbsplugins.de/archive/2019-05-14/New_column_names_in_an_Excel_d/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.4pr8](https://www.mbsplugins.de/archive/2014-11-01/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.4pr5](https://www.mbsplugins.de/archive/2014-10-12/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2025, Seite 27](https://filemaker-magazin.de/neuigkeit/4282-Appetithappen-FMM_202501)
- [Ausgabe 5/2022, Seite 23](https://filemaker-magazin.de/neuigkeit/4196-Appetithappen-FMM_202205)

This function checks for a license.

Created 18th August 2014 , last changed 25th January 2026

  
[XL.List](XLList.md) - [XL.LoadBookInfo](XLLoadBookInfo.md)

[HTML Version](XLLoadBook.shtml)