NPOI Connection

Parent Previous Next

Creating an Excel NPOI DataSource

Use the Sources Manager Tree or the DataNode Configuration dialogue to Create or Edit a new Excel NPOI DataSource.

NPOI DataSource can also be configured by dragging and dropping the target file directly onto the Sources Manager Tree. The DataNode, DataSource and DataView will be automatically configured to point at the first sheet of the workbook, with all columns read only.

Configuring the Excel NPOI DataSource

To setup a NPOI Excel DataSource simply provide the workbook full path, with extension. It can be .xls or .xslx.


TIPS


If you browse to a file located on a network drive the workbook path will be resolved as a UNC path.


When using the DataSource to write data back to the Excel file, you can choose to create a Backup File. The NPOI external library used by BimSens is in development and using it to write Excel file can lead to corrupted workbooks. To ensure you do not lose any data keep the Backup option activated. The backup option will create 2 files:

Uncheck the Evaluate Formulas option if your workbook contains formulas that are not supported by the Excel NPOI DataSource. Support for Excel syntax is progressively added to the NPOI library and the Excel NPOI DataSource is updated accordingly, but there are still functions that are not supported..


warning


When a non-supported function is detected by BimSens or when the option Evaluate Formulas is unchecked, the DataView is forced to read only

Get Change Notifications

NPOI Excel DataSource support change notification: the DataView can be automatically refreshed to show modification to the workbook that have been made outside of BimSens or by another user. To enable notifications check the corresponding option and choose a Waiting Timer.

Waiting Timer are used by BimSens to wait for the file to be available again: when the file is open by a programme requiring exclusive locks on the file such as Excel, BimSens cannot refresh the DataView until the file is released (closed in Excel). BimSens will wait the specified amount of time for the user to close Excel after having saved its changes before trying to refresh. If the file is still open after that time, BimSens will raise an error as it cannot access the file.

For BimSens to refresh the data when notification are received, you must activate the automatic refresh option from the Option dialogue, Refresh page.

Configuring the Excel NPOI DataView(s)

You can load several DataViews from the same workbook each looking at different sheets or subset of the data of the same sheet. To create a new DataView, from the DataSource Configuration dialogue click the New DataView button. Refer to the section Configuring a DataView for more ways to create and edit DataViews.

An Excel NPOI DataView can be configured to look at any sheet of the workbook:

TIPS


The number of columns being loaded has a direct impact on the performance of the refresh operation, especially columns calculated by a Formula; try only loading the necessary columns.

For instance when using several columns to calculate a result in multiple steps, only select the column of the final result.

Click the OK button to finish the configuration.

About Data Types

Unlike Excel, BimSens only accepts a single data type per column and it will try to use the best type to display the data for each column. If no compatible type is found it will default back to String (Text) which can display all values.

TIPS


By default date are stored as double in Excel and BimSens will only suggest the date type if the cells are formatted for dates. In other situations you will have to force the Date type.


warning


When you Force the type of a column, all values from that column that are not of the correct type will be ignored and shown as blank when the data is loaded.

Editing of the data from the DataView

You can set a column to be editable via BimSens simply by checking the Editable box.

Consider having the Backup File option of the DataSource active when using the NPOI DataView in Write mode.

Defining Allowed Values

By default, when editing a column, the user can enter any value of the proper data type. By defining Allowed Values for a column, you restrict the user input and the editing form will display a drop down with the values you defined only.

To define Allowed Values for a column: