ReadExcelFile (FPScript)

21.09.2021

Reads one or more data sets from an Excel file.

Syntax

ReadExcelFile(Path, [ Schema ], [ Sheet = 0 ], [ ChannelIdentifier ], [ CalendarTime = FALSE ], [ Signal = FALSE ], [ DataRange = READEXCEL_DR_COMPLETE ], [ RangeFrom ], [ RangeTo ] [ , Duration ])

 

The syntax of the ReadExcelFile function consists of the following parts:

Part

Description

Path

String with the path of the file to be read.

Permitted data structures are scalar value. Supported data types are string (file name).

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Schema

Alias name of a schema stored in the project database that contains all of the settings necessary for importing, or the path of an XML schema stored on the hard drive, or all necessary settings as an XML string.

Permitted data structures are scalar value. All data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Sheet

Name or index (starting at 0) of the Excel worksheet to be used.

Permitted data structures are scalar value. Supported data types are 16-bit integer, 32-bit integer, 64-bit integer und string.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value 0.

ChannelIdentifier

Number of the channel or channels to be read (starting at 1). If no channel number is specified, all channels are returned, or, if present, the selection from the chosen schema is used. If a scalar value is specified as ChannelIdentifier, the channel is returned as a data series or signal. Otherwise, the channels are returned as a list.

Permitted data structures are scalar value und data series. All integral data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

CalendarTime

Boolean value specifying that the time data are to be read as calendar times. Otherwise, the X component provides the time in seconds since the start of the measurement. This argument may not be supported for the selected format and in that case may be ignored.

Permitted data structures are scalar value. Supported data types are Boolean value.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value FALSE.

Signal

Boolean value specifying that elements are to be imported as signals. This argument may not be supported for the selected format and in that case may be ignored.

Permitted data structures are scalar value. Supported data types are Boolean value.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value FALSE.

DataRange

Value that specifies the type of data range to create.

The argument DataRange can have the following values:

Constant

Meaning

READEXCEL_DR_COMPLETE

The full data range is read.

READEXCEL_DR_FROMTO

The data range from RangeFrom to RangeTo will be read.

READEXCEL_DR_FROMDURATION

The data range from RangeFrom to RangeFrom + Duration will be read.

READEXCEL_DR_DURATIONLAST

The data range with the duration Duration up to the last value will be read.

READEXCEL_DR_FIRSTDURATION

The data range with the duration Duration from the first value on will be read.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value READEXCEL_DR_COMPLETE.

RangeFrom

Absolute or relative time of the first value to read if the data is not to be read from the beginning. If the X data set contains calendar time values, a calendar time value is expected here; otherwise a floating point value is expected. If the argument is not specified or no X data set is assigned to the data sets, the data is read from the first value.

Permitted data structures are scalar value. All real data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

RangeTo

Absolute or relative time of the last value to read if the data is not to be read to the end. If the X data set contains calendar time values, a calendar time value is expected here; otherwise a floating point value is expected. If the argument is not specified or no X data set is assigned to the data sets, the data is read up to the last value.

Permitted data structures are scalar value. All real data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Duration

Duration of the data range. This value must be specified if the element DataRange has the value READEXCEL_DR_FROMDURATION, READEXCEL_DR_DURATIONLAST or READEXCEL_DR_FIRSTDURATION. This argument is only supported when an X data set has been specified.

Permitted data structures are scalar value. All real data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Remarks

When importing a file using the Import Wizard, it is possible to save the schema with the settings in the template database. In this case, the alias name can be used to access the settings. If the settings are not saved as a schema, you can also pass the settings directly to the function as an XML string. In the Organizer dialog box, you can store a saved schema in an XML file. You can also access this type of XML file directly in the ReadExcelFile. If an entry in the file cannot be interpreted as a number, then a void floating point value is entered at the corresponding location in the result.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

ReadExcelFile("c:\\examples\\file.xlsx", 1, "", 2)

Reads the second channel from the file c:\examples\file.xlsx. Default settings are used for the import.

See Also

Excel File Import Wizard

Data Import

Share article or send as email:

You might be interested in these articles