OpenDocument Spreadsheet - Open/Create workbook

Declaration

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

Related Topics    

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.

NOTE: Unlike Automate's Excel activities, the 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 in order 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.

Parameters

Session

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 file name of the workbook document in which to open. If the Get document by parameter is set to Create, specifies the path and file name 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 file name 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 selected, the newly created workbook will overwrite any workbook with the same name that exists in the destination. If disabled (default), an existing workbook with the same name will not be overwritten, however, an error will occur during runtime as a result of matching file names. This parameter is active only if the Get document by parameter is set to Create.

Description

Error Causes

On Error

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

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.

Copy
<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 ACTIVITY="end" />
<AMODS ACTIVITY="close_workbook" SESSION="OPENDOCSession1" />