Spreadsheets in ACP1 - Old

Revision as of 00:27, 16 April 2015 by Max (talk | contribs)

ACP can read from and write to a spreadsheet using the same spreadsheet functions as in Analytica. By default ACP looks for spreadsheet file in the same directory as the model. But, if you set Dialog: True in the SpreadsheetOpen, it prompts the user for a spreadsheet file to upload from his computer. You can also set a model to download a spreadsheet from ACP -- for example, with saved results.

For more information about spreadsheet functions in Desktop Analytica, see: Functions To Read Excel Worksheets Functions to Write Data to Excel Worksheets

Opening Spreadsheets in ACP

ACP treats SpreadsheetOpen(filename) in the Definition of a variable almost the same as in Desktop Analytica: If it finds a spreadsheet file with that name in the same directory as the ACP model, it opens that file without comment. If it can't find a file with that name -- or if you add set «showDialog» parameter to true:

SpreadsheetOpen(filename, showDialog)

ACP prompts the user with a file browser dialog to upload a spreadsheet from the computer on which they running ACP. If the user provides a file, it uploads it into the ACP directory with that name, and the ACP model opens the file. If the ACP directory already contains a file with that name, ACP asks if you want to overwrite the existing file with a new file to be uploaded. Like in Desktop Analytica, the user does not have to select a spreadsheet with the same filename as the «filename» parameter but after the model is closed is ACP will not remember any filenames aside from what is used in the «filename» parameter.

Unlike Desktop Analytica, ACP may only prompt a user to upload a spreadsheet once after the model is opened. If you would like Analytica to prompt a user multiple times, the definition of the SpreadsheetOpen() variable may need to be reset. For example, if Va1 calls SpreadsheetOpen(), you can create a duplicate of Va1 called Va2 and use a button script to set the definition of Va1 as the definition Va2 like so:

Definition of Va1: SpreadsheetOpen('example.xls',True)
Definition of Va2: SpreadsheetOpen('example.xls',True)

OnClick for Reset Button
Definition of Va1 := Definition of Va2;

After pressing the Reset button, the user will be able to upload a new spreadsheet when Va1 is evaluated regardless if a spreadsheet has already been uploaded.

Downloading Spreadsheets in ACP

If you are an Author or Administrator in your ACP account, you can download a spreadsheet (or any file) from the ACP directory view: Simply select the radio button for the spreadsheet file you want, and then click the [Download] button.

While playing a model

A common scenario is that the results of an Analytica model get written to a spreadsheet while playing a model. One can add a button to their model which can be used for downloading the spreadsheet file containing the run model results.

To download a spreadsheet in ACP while playing a model, simply add "download_spreadsheet:abcxyz.xls" to the CloudPlayerStyles Attribute of a button. When the button is pressed in ACP, a pop-up will open that directs the user to download the spreadsheet file "abcxyz.xls". Tip, you can find out the filename of the spreadsheet opened using Analytica's built-in SpreadsheetInfo function with the second parameter set to 'Name'.

You can also simply put "download_spreadsheet" into the CPS attribute of a button. In this case, if a spreadsheet was uploaded earlier while the model was being played, then pressing button will cause the spreadsheet to be downloaded.

Comments


You are not allowed to post comments.