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.

 or register to reply.

Notify Moderator