我希望在Google工作表中创建一个按钮并为其指定一个脚本,该脚本会根据单元格中的特定字符串将用户带到特定的工作表。
我试图将其他答案合并到类似问题但我还没有成功!
这就是我目前所处的位置:
public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
// height and width larger than the requested height and width.
while ((halfHeight / inSampleSize) >= reqHeight
&& (halfWidth / inSampleSize) >= reqWidth) {
inSampleSize *= 2;
}
}
return inSampleSize;
}
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
}
我真的,真的是新来的代码,所以请原谅以上如果它已经离开了!
感谢您提供的任何帮助:)
答案 0 :(得分:0)
试试这个:
function sheetChanger() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("Lookup");
var range = first.getRange("B5:B5");
range.activate();
}
再看一遍,我想我误解了你要做的事情。如果你想跳转到Lookup!B5那么以上就行了。
如果你需要跳转到Lookup!B5中命名的工作表,那么这将有效:
function sheetChanger() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("Lookup");
var range = first.getRange("B5");
var cell = range.getCell(1,1);
var sheet = cell.getValue();
Logger.log(cell.getValue());
ss.getSheetByName(sheet).getRange("A1").activate();
}
答案 1 :(得分:0)
在我对编码的可怕知识中,我要求脚本查看B5中的数据,但不要接受它......
function sheetchanger() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Lookup');
var cell = sheet.getRange("B5").getValue();
ss.setActiveSheet(ss.getSheetByName(cell));
}
我只需要在其上添加.getValue!