Cells to Dataset

When performing Excel related tasks, you often need to run the same block of actions on each cell in a range of cells. You can use the 'Cells to Dataset' action to retrieve the contents of a range of cells in a Microsoft Excel document and combine a looping statement using the Loop Dataset action to identify each cell, one at a time, and run the operation. Populates a dataset with a selected range of cells in an established Excel session.

Declaration

<AMEXCELCELLSTODATASET RESULTDATASET="text" STARTCELLROW="number" STARTCELLCOLUMN="number" ENDCELLROW="number" ENDCELLCOLUMN="number" />

Example

This example opens an existing spreadsheet, retrieves the data contained in the first 3 rows of column A and populates a dataset with the results. The data is then looped through. A message box is contained inside the loop to display the value of the current row. In order for this task to work, make sure to edit the properties of the 'Open Workbook' action (step 1) to point to a valid Excel file that contains data in the first 3 rows and columns.

<AMEXCELOPENWORKBOOK WORKBOOK="C:\Temp\myexceldocument.xlsx" />

<AMEXCELCELLSTODATASET RESULTDATASET="mydataset" STARTCELLROW="1" STARTCELLCOLUMN="1" ENDCELLROW="3" ENDCELLCOLUMN="1" />

<AMLOOP TYPE="DATASET" DATASET="mydataset">

<AMSHOWDIALOG>The value of row %mydataset.CurrentRow%, column A is %mydataset.A%.

</AMSHOWDIALOG>

</AMLOOP>

<AMEXCELCLOSEWORKBOOK SAVE="NO" />

See Also: Create Workbook, Open Workbook, Close Workbook, Add Worksheet, Activate Worksheet, Get Cell, Set Cell, Dataset to Cells, About Datasets

AWE's Excel actions use Microsoft's Excel automation engine to perform their work. Therefore, Microsoft Excel must be licensed and installed on the system in order for these actions to work. Excel objects run in the context of the user executing them. If EFT is running as a Local System, then the Excel object is executed using the Local System profile. Before using an Excel action in Event Rules, refer to Globalscape Knowledgebase article #11089 for important information.

This action is only useful in conjunction with other Excel actions. It is not possible to use AWE's Excel actions on a spreadsheet that was not opened by the Open Workbook action or created by the Create Workbook action.

General Tab

Property

Type

Required

Default

Markup

Description

Session Name

Text

Yes

ExcelSess1

SESSION="ExcelSess7"

The name of the session to associate with this Excel action. Numerous sessions can exist within a single task allowing several spreadsheets to be open simultaneously. If working with only one document, this can remain at the default session name, which is Excelsess1.

Create and Populate Dataset

Text

Yes

(Empty)

RESULTDATASET="datasetname"

The name of the dataset that should be populated with the contents of the desired cells at runtime.

More on datasets

Start Row

Number

No

1

STARTCELLROW="3"

The start row of the cells where the data should be retrieved. If a value is entered in this parameter, you must also enter a value in the STARTCELLCOLUMN, ENDCELLCOLUMN and ENDCELLROW parameters.

This parameter is available only if the Cell by position option is enabled. If the Cell by reference option is enabled, this parameter is ignored.

End Row

Number

No

2

ENDCELLROW="4"

The end row of the cells where the data should be retrieved. If a value is entered in this parameter, you must also enter a value in the STARTCELLCOLUMN, ENDCELLCOLUMN and STARTCELLROW parameters.

This parameter is available only if the Cell by position option is enabled. If the Cell by reference option is enabled, this parameter is ignored.

Start Column

Number

No

1

STARTCELLCOLUMN="2"

The start column of the cells where the data should be retrieved. If a value is entered in this parameter, you must also enter a value in the ENDCELLCOLUMN, STARTCELLROW and ENDCELLROW parameters.

This parameter is available only if the Cell by position option is enabled. If the Cell by reference option is enabled, this parameter is ignored.

End Column

Number

No

3

ENDCELLCOLUMN="5"

The end column of the cells where the data should be retrieved. If a value is entered in this parameter, you must also enter a value in the STARTCELLCOLUMN, STARTCELLROW and ENDCELLROW parameters.

This parameter is available only if the Cell by position option is enabled. If the Cell by reference option is enabled, this parameter is ignored.

Start Cell Reference

Text

No

A1

STARTCELLREF="C1"

The start cell reference of the cells where the data should be retrieved. This is an alternate method to specifying the row and column of the desired cell. If specified, the STARTCELLCOLUMN, ENDCELLCOLUMN, STARTCELLROW and ENDCELLROW parameters are ignored. If specified, the ENDCELLREF parameter must also be specified.

End Cell Reference

Text

No

C2

ENDCELLREF="E3"

Specifies the end cell reference of the cells where the data should be retrieved. This is an alternate method to specifying the row and column of the desired cell. If specified, the STARTCELLCOLUMN, ENDCELLCOLUMN, STARTCELLROW and ENDCELLROW parameters are ignored. If specified, the STARTCELLREF parameter must also be specified.

Use specific worksheet

Text

No

Sheet1

WORKSHEET="Sheet3"

If enabled, indicates that the data will be retrieved from a specific worksheet instead of the currently active worksheet. Enter the name of the appropriate worksheet in the text box. If left blank or omitted, the current active worksheet will be used.

Description Tab

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Tab

The Error Causes tab properties allow you to instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Tab

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Description

This action includes the Description tab for entering a custom step description.

More about setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More about Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, % Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables

More on expressions

More on the expression builder