MS Excel

The MS Excel functions allow you to retrieve data from, and write data to, MS Excel files.

The file on which the function is to be run must not be open in Excel when the function is performed.

The functions are divided into two groups, With Excel and Without Excel:

The difference between the two sets of functions is as follows:

  • With Excel

    These functions do require that Excel be installed on the machine on which the solution is being run. Excel is opened every time one of these functions is performed. These functions therefore take longer to perform than the functions under Without Excel.

  • Without Excel

    These functions do not require that Excel be installed on the machine on which the solution is being run. The function is performed without opening Excel and is therefore performed very quickly.

    These functions are valid only for Excel files generated using Office 2007 onwards (i.e. that have .XLSX extensions).

    The Excel file must not be open in Excel when one of these functions is to be performed.

All Excel functions that read data from Excel files, including functions under With Excel and under Without Excel, can cause problems that prevent the project from running if the Excel file includes hyperlinked content. Hyperlinks should be removed from files that will be accessed by these functions.

MS Excel Functions - With Excel

(Available from version 7.0 onwards.)

These functions do require that Excel be installed on the machine on which the solution is being run. Excel is opened every time one of these functions is performed. These functions therefore take longer to perform than the functions under Without Excel.

Many of the functions in this library are available in two versions, as in the examples below.

  • From Active Excel

    These functions are performed on the Excel file that is currently open and active in Excel. The Excel window itself must be the active window.

    These functions do not require that you specify the path or name of the Excel file - they are performed on whichever Excel file is currently open and active.

  • From Specified Excel

    These functions are performed the Excel file specified within the function's full path parameter.

    The specified Excel file must not be open in Excel when one of these functions is to be performed.

Example Files

An individual example is provided for each function described below.

Functions

MS Excel Functions - Without Excel

(Available from version 7.1 onwards.)

These functions do not require that Excel be installed on the machine on which the solution is being run. The function is performed without opening Excel and is therefore performed very quickly.

These functions are valid only for Excel files generated using Office 2007 onwards (i.e. that have .XLSX extensions).

The Excel file must not be open in Excel when one of these functions is to be performed.

Example Files

An individual example is provided for each function described below.

Supported Time and Date Formats

When reading data from an Excel sheet (see Get Excel Cell Value, Get Excel Column Values, Get Excel Range Values, and Get Excel Row Values), time and date data will only be read correctly for dates entered in the formats listed below.

Format

Example

dd-mmm-yyyy hh:mm AM/PM 05-Jan-2019 02:00 AM
hh:mm AM/PM 02:00 AM
[$-en-US]dddd, mmmm d, yyyy Saturday, January 5, 2019
m/d/yyyy 1/5/2019
dd-mmm-yy 12-Jan-20

Time formats with a single hour digit (h) are not supported.

Functions

Best Practices

Below are best practices related to the MS Excel library functions.