Dataset to Cells Action Icon

Dataset to Cells

Declaration

<AMEXCELDATASETTOCELLS DATASET="text" CELLREF="text" WORKSHEET="text" />

See Also

Activate Cell | Activate Worksheet | Add Worksheet | Cells to Dataset | Close Workbook | Create Workbook | Dataset to Cells Action | Get Active Cell | Get Active Worksheet | Get Cell | Open Workbook | Set Cell

Description

Sets the text of a selected cell range in an established Excel session with the values contained in a dataset.

IMPORTANT: AutoMate'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.

Practical Usage

Mainly used to enter data onto an Excel document that was previously created or opened using AutoMate's Create Workbook or Open Workbook actions.

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

Parameters

General Properties

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.

Dataset

Text

Yes

(Empty)

DATASET="mydatasetname"

The name of the AutoMate dataset holding the data that should be set to the desired cell or range of cells at runtime. More details on datasets can be found below under Notes.

Row

Number

No

1

STARTCELLROW="3"

The row of the upper left cell where the data should be set. If specified, the CELLCOLUMN parameter must also be specified.

Column

Number

No

1

CELLCOLUMN="2

The column of the upper left cell where the data should be set. If specified, the CELLROW parameter must also be specified.

Cell Reference

Text

No

A1

CELLREF="B3"

Specifies the reference of the upper left cell (i.e. B3 or C2) where the data should be set. This is an alternate method to specifying the row and column of the desired cell. If this parameter is used, the CELLROW and CELLCOLUMN parameters are ignored.

Use Specific Worksheet

Text

No

3

WORKSHEET="Sheet1"

If enabled, indicates that the data will be set to a specified worksheet. The worksheet name can be entered in the provided text box. If left blank or omitted, the current active worksheet will be used.

Include Column Names

Yes/No

No

No

INCLUDECOLUMNNAMES="YES"

If enabled, output will include the dataset column names (i.e. the text contained in the column headers) as the first row. The dataset values are then output in subsequent rows. This option is disabled by default.

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 provided textbox. If left blank or omitted, the current active worksheet will be used.

Description Properties

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 Properties

The Error Causes tab properties allows 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 Properties

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

Notes

Datasets

A dataset is a multiple column, multiple row container object. This action creates and populates a dataset, the fields contained within that dataset are determined by the query that was executed. For example if the following query is executed:

 

SELECT firstname, lastname, company from customer where city='Los Angeles'

 

 

Then the following dataset would be generated:

datasetname
|--firstname
|--lastname
|--company
 

A record (row) is created for each record (row) that is retrieved from the server. To access this data use the Loop Dataset Action <AMLOOPDATASET> to loop through the records, inside the loop you can extract the data from the field of your choice (from the current record) by using an embedded expression such as the one that follows:

 

%mydatasetname.firstname%

 

 

Or you could combine two fields together like this:

 

%mydatasetname.firstname + " " + mydatasetname.lastname%

 

 

Embedded Expressions such as these can be used in any parameter in any action. So, to display the data in a message box the AML code would look like this:

 

<AMMESSAGEBOX MESSAGETEXT="%mydatasetname.firstname%" WINDOWTITLE="The firstname of the current record is">

 

 

At runtime the text %mydatasetname.firstname% is replaced by the contents of the subject of the current record.

Common Name Description

The table below describes the common set of columns that a dataset creates (assuming the dataset name assigned is theDataset).

Name

Data Type

Return Value

theDataset.CurrentRow

Number

The current row that will be accessed in the dataset by an expression that does not contain a specific row index.

theDataset.TotalRows

Number

The total number of rows in the dataset.

theDataset.TotalColumns

Number

The total number of columns (not including the static columns) in the dataset.

theDataset.ExecutionDate

Date

The date and time the dataset was created and populated.

theDataset.RowsAffected

Number

The number of rows affected by an update.

theDataset.SQLQuery

Text

The SQL Query that was used to generate this dataset (If a SQL Query was not used, this value is empty).

theDataset.Datasource

Text

The datasource used for the SQL Query, if applicable.

theDataset.ColumnNames

Text

A comma-delimited list of the column names in the dataset.

 

More on datasets

Custom Description

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

More on setting custom step description

Standard Error Handling Options

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

More on 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

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description - This sample task opens two separate Excel documents. It retrieves data from one document and saves it to dataset. Thereafter, it writes the contents of the newly created dataset to the other Excel document. The task concludes by closing both Excel documents.

 

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

<AMEXCELOPENWORKBOOK WORKBOOK="c:\excellfile.xls" />

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

<AMEXCELDATASETTOCELLS DATASET="mydataset" CELLREF="A1" WORKSHEET="Sheet1" />

<AMEXCELCLOSEWORKBOOK />

<AMEXCELCLOSEWORKBOOK />

 

↑ Top of Page