OpenDocument Spreadsheet - Open/Create Workbook

Declaration

<AMODS SESSION="text" CONNECTBY="text (options)" 
WORKBOOK="text" OVERWRITE="YES/NO" TEMPLATENAME="text" />

Description: Opens an existing workbook or creates a new workbook and establishes a unique session in which subsequent OpenDocument Spreadsheet activities can link to. A session is exceptionally useful as a means of organizing and encapsulating a large collection of activities required to accomplish a particular task/operation.

IMPORTANT: OpenDocument Spreadsheet activities do not rely on Microsoft's Excel engine to perform their work, therefore, Microsoft Excel does not need to be installed on the system to use these activities. Supported file types include Excel (*.xls, *.xlsx, *.xlsb, *.xlsm ), Open document spreadsheet (*.ods) and CSV (Comma Separated Value) files (*.csv).

Practical Usage

Commonly used to create a new session in which other OpenDocument Spreadsheet activities can link to. Sessions typically represent a combination of steps that are used to complete a specific process. Creating sessions enables you to build and organize more customized tasks. Additionally, sessions can eliminate redundant entry of identical parameters that may be required by several activities.

Session Parameters

Property

Type

Required

Default

Markup

Description

Get document by

Text (options)

Yes

(Empty)

  1. CONNECTBY="open_workbook"

  2. CONNECTBY="create_workbook"

Indicates where the source workbook should originate from. The available options are:

  • Open (default) - The source will be an existing workbook document which will be opened at runtime.

  • Create - The source will be a newly created workbook document.

Session

Text

Yes

OpenDocSession1

SESSION="Session1"

The session name to be created. This allows subsequent OpenDocument Spreadsheet activities to be linked to this session. Numerous sessions can exist within a single task allowing several OpenDocument Spreadsheet documents to be open simultaneously. The default session name is OpenDocSession1.

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 workbook document in which to open. If the Get document by parameter is set to Create, specifies the path and filename that the newly created workbook document will be saved to.

Password to open (optional)

Text

No

(Empty)

OPENPASSWORD="encrypted"

The password required to open the workbook 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. 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 any workbook with the same name that exists in the destination. If set to NO (default), an existing workbook with the same name will not be overwritten, however, an error will occur during runtime as a result of matching filenames. This parameter is active only if the Get document by parameter is set to Create.

Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description: This sample task opens a workbook, populates a dataset with data regarding the spreadsheets that it contains. The dataset is then looped. During each iteration, information about the current spreadsheet is displayed in a message dialog. The last step closes the workbook, ths ending the session.

<AMODS SESSION="OPENDOCSession1" 
WORKBOOK="C:\temp\Employees.xls" />
<AMODS ACTIVITY="list_worksheet" 
SESSION="OPENDOCSession1" RESULTDATASET="theSheets" />
<AMLOOP ACTIVITY="dataset" DATASET="theSheets">
<AMSHOWDIALOG WINDOWTITLE="Worksheet 
Information">Worksheet Name: %theSheets.WorksheetName%
Worksheet Index: %theSheets.WorksheetIndex%
Is worksheet visible?: %theSheets.IsVisible%
Is worksheet active?: %theSheets.IsActive%</AMSHOWDIALOG>
</AMLOOP><AMODS ACTIVITY="close_workbook" 
SESSION="OPENDOCSession1" />