The following tutorial describes how to output the following information from an EPC to an Excel sheet using a report:
First you need all selected models over which you want to iterate:
var aModels = ArisData.getSelectedModels();
Use the following method to determine the name of the current model:
var sModelName = oModel.Name(nLocale); // Name of current model
The 'ObjOccListFilter' method returns all object occurrences of the relevant model, in this case all functions.
var oFuncOccs = oModel.ObjOccListFilter(Constants.OT_FUNC);
Use the following expression to determine all incoming connections:
var aCxnOccs = oFuncOccs[j].Cxns(Constants.EDGES_IN);
In this case, only connections of the 'carries out' type are to be included in the evaluation, which means that the connection type must be checked:
if(aCxnOccs[k].CxnDef().TypeNum()==Constants.CT_EXEC_1 || aCxnOccs[k].CxnDef().TypeNum()==Constants.CT_EXEC_2)
If this query returns 'true', determine the relevant source object and check whether it is of type 'Person type':
var oSourceObjOcc = aCxnOccs[k].SourceObjOcc(); if (oSourceObjOcc.ObjDef().TypeNum() == Constants.OT_PERS_TYPE)
If the source object corresponds to this type, the following information is output:
oOutputFile.TableCell(sModelName, 20, getString("TEXT_1"), 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); var nSource = oSourceObjOcc.ObjDef().Name(nLocale); oOutputFile.TableCell(nSource, 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); var nCxn = aCxnOccs[k].CxnDef().ActiveType(); oOutputFile.TableCell(nCxn, 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); oOutputFile.TableCell(oFuncOcc.ObjDef().Name(nLocale), 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0);
The complete report with all iterations and the entire output looks as follows:
var oOutputFile = Context.createOutputObject(); // Output object var nLocale = Context.getSelectedLanguage(); // Selected database language var aModels = ArisData.getSelectedModels(); for (var i = 0; i < aModels.length; i++) { oOutputFile.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0); oOutputFile.TableRow(); oOutputFile.TableCell("ModelName", 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_CENTER | Constants.FMT_VTOP, 0); oOutputFile.TableCell("Actor", 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_CENTER | Constants.FMT_VTOP, 0); oOutputFile.TableCell("Connection", 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_CENTER | Constants.FMT_VTOP, 0); oOutputFile.TableCell("Task", 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_CENTER | Constants.FMT_VTOP, 0); var oModel = aModels[i]; // Current model var sModelName = oModel.Name(nLocale); // Name of current model //functions var oFuncOccs = oModel.ObjOccListFilter(Constants.OT_FUNC); for (var j = 0; j < oFuncOccs.length; j++){ var oFuncOcc = oFuncOccs[j]; var aCxnOccs = oFuncOccs[j].Cxns(Constants.EDGES_IN); for(var k=0; k<aCxnOccs.length; k++){ if(aCxnOccs[k].CxnDef().TypeNum()==Constants.CT_EXEC_1 || aCxnOccs[k].CxnDef().TypeNum()==Constants.CT_EXEC_2){ // check type of source object var oSourceObjOcc = aCxnOccs[k].SourceObjOcc(); if (oSourceObjOcc.ObjDef().TypeNum() == Constants.OT_PERS_TYPE){ oOutputFile.TableRow(); oOutputFile.TableCell(sModelName, 20, getString("TEXT_1"), 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); var nSource = oSourceObjOcc.ObjDef().Name(nLocale); oOutputFile.TableCell(nSource, 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); var nCxn = aCxnOccs[k].CxnDef().ActiveType(); oOutputFile.TableCell(nCxn, 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); oOutputFile.TableCell(oFuncOcc.ObjDef().Name(nLocale), 20, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); } } } } oOutputFile.EndTable(sModelName, 100, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0); } oOutputFile.WriteReport();
Let's see if any more wishes will come true...
I looked through your script, and didn't understand how did you split cells ? modelname colomn contains 9 lines. in the loop you wold have 9 lines with modelname STRINGs.
Thanks
I'am new to ArisScripting and last week was wondering how it was possible to merge cell-s and collumns in excell report. So , when I saw your report in the picutre, you have ModelName ->"Test" only once (in one cell for all 9 columns), and you have merged 9 rows (Modelname column). But according to your code the output will have "Test" (modelname) 9 times in each row. Am I right ? :)
Ah okay, now I know what you mean:). My report only provides the data, not the layout of the picture above. That means that my report outputs the model name 9 times, for example, but does not merge the cells as shown in the picture above.
Welcome to the world of ARIS scripting:-)