Tuesday, July 16, 2013

Google Spreadsheets Scripts - How to Transpose in Google Apps Scripts


( by Maggie )

I'm trying to get the same result as in using =transpose(range) but with google app scripts.
Any ideas?

Thank you


Have a look at the following screenshot:

I have the following formula in Cell E1:


the above formulas is a custom function that I have written and inserted in Script.

Have a look at the following code:

function KishanTranspose(a){
  return Object.keys(a[0]).map( function (c) { return a.map(function (r) { return r[c]; }); }  );

put the above code in your script editor, and then you can use it directly in your Google Spreadsheet or you can use its functionality in the Google Apps Script.

And If you are not much familiar with scripts then check out the following link:

I hope the above solution will help you, and if you need more help then please do comment below on this blog itself, I will try to help you out.

I also take up private and confidential projects:
If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: http://igoogledrive.blogspot.com/2012/09/donate.html 


1 comment: