ONLYOFFICE Workspace 12.5: enhanced security, optimized document management, Dark theme, and more
ONLYOFFICE Workspace 12.5 released

SetValue question

let workSheet = Api.GetActiveSheet();
let data = [[“A1”,“B1”],[“A2”,“B2”],[“A3”,“B3”]];
workSheet.GetRange(“A1:B3”).SetValue(data);

How to transpose a value? I mean result like this:

for (let j = 0; j < data.length; j++) {
workSheet.GetRangeByNumber(0+j,0).SetValue(data[j][0]);
workSheet.GetRangeByNumber(0+j,1).SetValue(data[j][1]);
}

Hello @pahetka

Do I understand it correctly that the goal is to swap values of certain cells in A column with the values of cells from B column?

Yes, can I set value in range by rows, not columns. In other words, is there a way to fill values, like in a second version of code but without using a loop?

Sorry for the late reply.

This might be a tough task but we are checking the situation.
I will update this thread once I have something to share.

1 Like

We ran some tests and, unfortunately, your scenario cannot be achieved without looping.
Based on this request we have created the enhancement suggestion to add possibility to change the direction of filling with SetValue parameter number 61056 into our internal tracker.

If you have any examples of VBA macros that is capable of performing such actions that you can share with us please feel free to share them so we can take notes for the suggestion.

1 Like