Google Spreadsheets脚本移动行

时间:2015-05-06 08:11:57

标签: google-apps-script google-sheets

就像你可以手动拖动一行一样,它会在你释放它时重新排列整个工作表,我希望能够在脚本中执行此操作,例如:sheet.moveRow(from,to);

这可能吗?

2 个答案:

答案 0 :(得分:3)

您需要先获取对范围的引用,然后使用范围的moveTo()方法。 Google Documentation - moveTo()

这是文档中的示例代码:

// The code below will move the first 5 columns over to the 6th column
 var sheet = SpreadsheetApp.getActiveSheet()
 sheet.getRange("A1:E").moveTo(sheet.getRange("F1"));

答案 1 :(得分:0)

当然你可以按照艾伦说的去做,但我会用 dtype='object') grp grp_n service_sk ... output indicator_p indicator_j 0 2131 Materials 21311 ... 0.819590 104.0 10.1906 1 2131 Materials 21311 ... NaN 184.0 10.1906 2 2131 Materials 21312 ... 1.503865 104.0 18.5241 3 2131 Materials 21312 ... NaN 184.0 18.5241 4 1113 Machines 11131 ... NaN 56.0 NaN 5 1113 Machines 11131 ... NaN 89.0 NaN 6 1113 Machines 11132 ... 1.725208 56.0 24.0000 7 1113 Machines 11132 ... 1.664246 89.0 24.0000 8 1113 Machines 11133 ... NaN 56.0 34.5340 9 1113 Machines 11133 ... 1.452587 89.0 34.5340 [10 rows x 8 columns]

documentation