Excel - Get Cell(s)

Declaration

<AMEXCEL ACTIVITY="get_cell" CONNECTBY="create_workbook" 
WORKBOOK="text" INVISIBLE="NO" WORKBOOKTEMPLATE="text" 
OVERWRITE="yes" 
SAVETYPE="save_as" DESTINATION="text" 
OVERWRITEDESTINATION="YES" 
ACTION="rangebyreference" RESULTDATASET="text" 
STARTCELLREF="text" ENDCELLREF="text" FIRSTROWCOLUMN="YES" 
WORKSHEET="text" />

Description: Retrieves the selected cell or range of cells and populates a variable with the value of a single cell or a dataset with the value of a range of cells.

IMPORTANT: Excel activities rely on Microsoft's Excel engine to perform their work; therefore, MS Excel must be licensed and installed on the system in order for these activities to function properly.

Practical Usage

Used to retrieve the contents of one or more cells in a Microsoft Excel document that was previously created using the Create Workbook action or opened using the Open Workbook action.

Resource Parameters

Property

Type

Required

Default

Markup

Description

Resource

 

 

 

 

Indicates where the source Excel document should originate from. This is a design mode parameter used only during task construction and configuration, thus, comprises no markup. The available options are:

  • File (default) - The source derives from an Excel file located on the system. This option is normally selected if only a single activity is required to complete the operation.

  • Session - The source Excel document is obtained from a pre-configured session created in an earlier step with the use of the Excel - Open/Create workbook activity. This option is normally selected if a combination of related activities are required to complete an operation. Consolidating several activities to a single session can eliminate redundancy. Moreover, a single task supports multi-session executions which can improve efficiency and speed up production.

Session

Text

Yes if Resource is set to Session

Excelsession1

SESSION="mySession"

The name of an existing session to associate this activity with. This parameter is active only if the Resource parameter is set to Session.

Get document by

Text (options)

Yes if Resource is set to File

Open

  1. CONNECTBY="open_workbook"

  2. CONNECTBY="create_workbook"

Specifies whether this activity will be performed on an existing Excel document or on a new one. This parameter is active only if the Resource parameter is set to File. The available options are:

  • Open (default) - This activity will be performed on an existing document that will be opened during runtime.

  • Create - This activity will be performed on a new document to be created during runtime.

File name

Text

Yes

(Empty)

WORKBOOK="C:\Temp\file.xls"

If the Get document by parameter is set to Open, specifies the path and filename of the Excel document in which to open. If the Get document by parameter is set to Create, specifies the path and filename of the Excel document in which to create.

Application is invisible

Yes/No

No

No

VISIBLE="NO"

If set to YES, specifies that the Excel window will not be displayed and all processing will occur in the background. This option should be set to NO during task construction and debugging but can be set to YES for production. The workbook is visible by default.

Password to open (optional)

Text

No

(Empty)

OPENPASSWORD="encrypted"

The password required to open the Excel document if it is password protected. This parameter is active only if the Get document by parameter is set to Open.

Password to modify (optional)

Text

No

(Empty)

MODIFYPASSWORD="encrypted"

The password required to modify the Excel document if it is password protected. This parameter is active only if the Get document by parameter is set to Open.

Create from template

Text

No

No

WORKBOOKTEMPLATE="C:\temp\file.xls"

If enabled, specifies the path and filename of a template file that already has preferred formatting in which to base the new workbook on. A template can include formatting, styles,  standardized text such as page headers and row and column labels, formulas, macros and custom toolbars. This parameter is active only if the Get document by parameter is set to Create. It is disabled by default.

Overwrite if workbook already exists

Yes/No

No

No

OVERWRITE="yes"

If set to YES, the newly created workbook will overwrite an existing workbook with the same name, If set to NO, an error will occur during runtime as a result of a matching filename. This parameter is active only if the Get document by parameter is set to Create.

On completion

Text (options)

No

Save

  1. SAVETYPE="save"

  2. SAVETYPE="save_as"

  3. SAVETYPE="do_not_save"

Specifies what to do with the document upon completion of this activity. The available options are:

  • Save - Save changes to the default location.

  • Save as - Save to the specified path and filename.

  • Do not save changes - Changes will not be saved.

Overwrite if workbook already exists

Yes/No

No

No

OVERWRITEDESTINATION="YES"

If set to YES, specifies that existing Excel files with matching names that exist in the destination will be overwritten. If set to NO, matching files will not be overwritten, however, a runtime error will occur as a result. Set to NO by default.

Description: This sample task opens an existing Excel document, retrieves the data contained in row 1/column1 of the active worksheet and populates a variable with the results. A message box is then used to display the value. In order for this task to work, make sure to edit the properties of the 'Open Workbook' action (step 2) to point to a valid Excel file that contains data in row 1 / column 1.

<AMVARIABLE NAME="myVar"></AMVARIABLE>
<AMEXCELOPENWORKBOOK WORKBOOK="C:\Temp\myexceldocument.xlsx" />
<AMEXCELGETCELL RESULTVARIABLE="myVar" CELLROW="1" CELLCOLUMN="1" />
<AMSHOWDIALOG WINDOWTITLE="CELL VALUE">The value of Row 1 / 
Column 1 is %myVar%.</AMSHOWDIALOG>