Based on our report with output of models and objects we now want to create a report which writes these information into a table.
This table should look like this:
Model name | Object name |
---|---|
<Name of model 1> | |
<Name of object 1> | |
<Name of object 2> | |
<...> | |
<Name of model 2> | |
<Name of object 1> | |
<Name of object 2> | |
<...> | |
<...> |
With table output it is also possible to generate output to Excel. So we add this format at the context of this report:
The only difference to generate table output is using different methods of the output object. All other methods like getting models or objects or reading their names are the same.
var oOutput = Context.createOutputObject(); // Output object var nLocale = Context.getSelectedLanguage(); // Selected database language oOutput.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0); oOutput.TableRow(); oOutput.TableCell("Model name", 50, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_YELLOW, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); oOutput.TableCell("Object name", 50, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_YELLOW, 0, Constants.FMT_BOLD | Constants.FMT_LEFT | Constants.FMT_VTOP, 0); var aModels = ArisData.getSelectedModels(); // Array of selected models for (var i = 0; i < aModels.length; i++) { var oModel = aModels[i]; // Current model var sModelName = oModel.Name(nLocale); // Name of current model oOutput.TableRow(); oOutput.TableCell(sModelName, 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0); oOutput.TableCell("", 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0); var aObjDefs = oModel.ObjDefList(); // All object definitions that have occurrences in the model for (var j = 0; j < aObjDefs.length; j++) { var oObjDef = aObjDefs[i]; // Current object definition var sObjName = oObjDef.Name(nLocale); // Name of current object oOutput.TableRow(); oOutput.TableCell("", 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0); oOutput.TableCell(sObjName, 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0); } } oOutput.EndTable("", 100, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT | Constants.FMT_VTOP, 0); oOutput.WriteReport();
To generate a table you have to use methods “BeginTable()” resp. “EndTable()” to open or close the table for writing. When you write into the table you have to start a new row using method “TableRow()” and finally you write the information into the current table cell with method “TableCell()”.
Here you can download the entire source code from the "Output models as table" report.
Note: This article describe how to develop a report in ARIS. See this post for links to similar articles.
Thanks Michael.. Appreciate you & Volker on these Report Script Tutorials.
Just wanted to point out a correction in the Line-20 of this report code, where it should be "j" and not "i"
var oObjDef = aObjDefs[j]; /
/ Current object definition
Note for Sebastian -- I tried typing as well as pasting the above code in the code editor but it resulted in below error. You may want to have it looked into:Line: 16Char: 1338
Error: Invalid argument
Code:0
URL: http://www.ariscommunity.com/users/mwz/2010-05-11-output-models-table
Hi Shankar,
IE7 was tested and worked here (tm). Hhhm, not sure what is going wrong in your case. Do you got some kind of script blocker installed or other stuff preventing scripts from executing?
About moving comments: Unfortunately, we can't move comments between posts easily, so we leave them here :-)