google-apps-script - How to take total count of spreadsheets on my Google Sheet File
问题描述
Is there any native formula built into the Google Sheet File that I can use to identify the total number of sheets (Inclusive of Hidden Sheets as well) on the file?
If there is no native formula, is there any script I can run to check the same.
解决方案
没有本机公式,但您可以使用脚本:
function SNAME(option) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet()
var thisSheet = sheet.getName();
if(option === 0){ // ACTIVE SHEET NAME =SNAME(0)
return thisSheet;
}else if(option === 1){ // ALL SHEET NAMES =SNAME(1)
var sheetList = [];
ss.getSheets().forEach(function(val){
sheetList.push(val.getName())
});
return sheetList;
}else if(option === 2){ // SPREADSHEET NAME =SNAME(2)
return ss.getName();
}else{
return "#N/A"; // ERROR MESSAGE
};
};
然后公式:
=COUNTA(SNAME(1))
推荐阅读
- php - Laravel CSV 导入仅保存 DB 中的最后一行(id 正确递增)
- flask - Redis 错误:('_kombu.binding.reply.celery.pidbox') 已从 Redis 数据库中删除
- binary - 数字系统:二进制与十六进制
- python-2.7 - 如何使用 Robotframework 解决 selenium:chromedriver 的 SessionNotCreatedException?
- reactjs - (p)React 避免在提交时不必要的重新渲染
- java - 如何在不关闭套接字的情况下通过套接字发送图像?
- angular - 如何在浏览器终端或其他显示 consol.log() 结果
- node.js - 文件迭代以在 node.js 中搜索相似的短语
- java - AndroidStudio - CompileError:(应用程序不断停止)-> RuntimeException:无法实例化活动
- c++ - TCP/IP - 在 C/C++ 中发送 HEX 数据包以控制中继板