Dear community,
I have to ask for help again. I've been dealing with the issue for several days now but I can't find a solution.

I have an array with nested arrays. An example of an array fragment is presented below. The array is sorted by the zero and second elements of nested arrays. All elements of nested arrays are string data type.

[[Process 1, Role 1, Function 1.1, Connection type A],
[Process 1, Role 1, Function 1.2, Connection type B],
[Process 1, Role 2, Function 1.3, Connection type C],
[Process 1, Role 2, Function 1.4, Connection type A],
[Process 2, Role 3, Function 2.1, Connection type A],
[Process 2, Role 14, Function 2.2, Connection type A],
[Process 3, Role 55, Function 3.1, Connection type A]]

I need to output this array to a table in Microsoft Word format. There are no problems with this. I also understand how to statically program the output of the table.

 

 

The problem is that I need to do a dynamic join of cells in the first and second columns. At the same time, the number of merged rows is random and can be any.

I have already come up with an algorithm that combines cells in the 1st column. But I can't come up with an algorithm that would combine the cells in the first and second columns.

In short, my algorithm is as follows:

In short, my algorithm is as follows:
1. I'm going through the array in search of a series of identical business processes following each other in the first column. The lengths of the series I write to an array.
2. I cut off a piece from a large array, equal in length to the first series.
3. I'm going through it, looking for a series of identical roles following each other in the second column. I also write the lengths of these series into an array (and I don't use it in any way yet).
4. I'm building a piece of the table.
5. I cut the next piece from a large array, equal in length to the second series.
6. I'm building a piece of the table.
7.... and so on

Below is the code for forming the body of the table. This code works and correctly forms a table with merged cells in the first column.
But I still can't figure out how to integrate the second part into it, combining cells in the second column.
Maybe I chose the wrong path at all, and there is a much simpler algorithm. But this is my second script in Aris and I'm still very inexperienced :(

    var countBpArray = count(bigArray,0);
    for (var i=0; i<countBpArray.length; i++){
        var peaceOfBigArr = bigArray.splice(0,countBpArray[i]);
        oO.TableRow();
        oO.TableCell(peaceOfBigArr[0][0],countBpArray[i],1,"Times New Roman",8,Constants.C_BLACK,Constants.C_TRANSPARENT,0,Constants.FMT_LEFT,0);
        oO.TableCell(peaceOfBigArr[0][1],1,1,"Times New Roman",8,Constants.C_BLACK,Constants.C_TRANSPARENT,0,Constants.FMT_LEFT,0);
        oO.TableCell(peaceOfBigArr[0][3],1,1,"Times New Roman",8,Constants.C_BLACK,Constants.C_TRANSPARENT,0,Constants.FMT_LEFT,0);
        oO.TableCell(peaceOfBigArr[0][4],1,1,"Times New Roman",8,Constants.C_BLACK,Constants.C_TRANSPARENT,0,Constants.FMT_LEFT,0);
        if (countBpArray[i]>1){
            for (var j=1;j<countBpArray[i];j++){
                oO.TableRow();
                oO.TableCell(peaceOfBigArr[j][1],1,1,"Times New Roman",8,Constants.C_BLACK,Constants.C_TRANSPARENT,0,Constants.FMT_LEFT,0);
                oO.TableCell(peaceOfBigArr[j][3],1,1,"Times New Roman",8,Constants.C_BLACK,Constants.C_TRANSPARENT,0,Constants.FMT_LEFT,0);
                oO.TableCell(peaceOfBigArr[j][4],1,1,"Times New Roman",8,Constants.C_BLACK,Constants.C_TRANSPARENT,0,Constants.FMT_LEFT,0);
            }
        }
    }

 

 

 or register to reply.

Notify Moderator