Skip to content

Instantly share code, notes, and snippets.

@eguweb
Last active Oct 23, 2019
Embed
What would you like to do?
// .setWrapStrategy(SpreadsheetApp.WrapStrategy.WRAP); //折り返す
// .setWrapStrategy(SpreadsheetApp.WrapStrategy.OVERFLOW); //はみ出す
// .setWrapStrategy(SpreadsheetApp.WrapStrategy.CLIP); //切り詰める
function WrapStrategy() {
var ss = SpreadsheetApp.openById('スプレッドシートID');
Logger.log(ss);
var sheets = ss.getSheets();
Logger.log(sheets);
//シートの数を取得しておく
var sheets_num = sheets.length;
Logger.log(sheets_num);
//先に変数を作っておく
var sheets_last_row = 0;
var sheets_last_column= 0;
for (i = 0; i < sheets_num; i++) {
var sheets_last_row = sheets[i].getLastRow();
var sheets_last_column = sheets[i].getLastColumn();
Logger.log(sheets_last_row);
Logger.log(sheets_last_column);
// → 全シートのセルを「はみ出す」に変更
sheets[i].getRange(2,1,sheets_last_row-1,sheets_last_column).setWrapStrategy(SpreadsheetApp.WrapStrategy.OVERFLOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment