创建锦标赛
编码级别:初级
时长:5 分钟
项目类型:使用自定义菜单的自动化操作
目标
- 了解该解决方案的用途。
- 了解 Apps Script 服务在解决方案中的作用。
- 设置脚本。
- 运行脚本。
关于此解决方案
创建最多 64 人或 64 支队伍的锦标赛对阵表。此解决方案会创建一个表示单淘汰赛的树状图。

运作方式
该脚本会循环遍历玩家列表,并确定小组赛需要多少轮。该脚本会设置 Bracket 工作表的格式以创建树状图,并将选手的名字添加到第一轮。
Apps 脚本服务
此解决方案使用以下服务:
电子表格服务 - 获取选手范围并为锦标赛创建树状图。
前提条件
如需使用此示例,您需要满足以下前提条件:
- Google 账号(Google Workspace 账号可能需要管理员批准)。
- 一个能够访问互联网的网络浏览器。
设置脚本
点击以下按钮,复制创建锦标赛对阵表示例电子表格。
复制
运行脚本
- 在复制的电子表格中,依次点击括号制作工具 > 创建括号。您可能需要刷新页面,此自定义菜单才会显示。
根据提示为脚本授权。如果 OAuth 意见征求界面显示此应用未经验证警告,请依次选择高级 >
前往 {Project Name}(不安全)以继续操作。
依次点击括号制作工具
> 再次创建括号。
切换到对阵表标签页,查看锦标赛对阵表。
查看代码
如需查看此解决方案的 Apps 脚本代码,请点击下方的查看源代码:
贡献者
此示例由 Google 维护,并由 Google 开发者专家提供帮助。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-21。
[null,null,["最后更新时间 (UTC):2024-12-21。"],[[["This script automates the creation of a single-elimination tournament bracket for up to 64 players or teams in Google Sheets."],["It uses the Spreadsheet service to get player data and generate the bracket diagram on a separate sheet."],["Users need a Google Account and web browser to utilize this tool, and can set it up by making a copy of the provided spreadsheet and running the script from the custom menu."],["The script randomly assigns players to the bracket, ensuring each spot is filled, and accommodates byes for an uneven number of participants."]]],["This script automates the creation of a single-elimination tournament bracket for up to 64 players. Utilizing the Spreadsheet service, it determines the necessary rounds, formats the \"Bracket\" sheet to display a tree diagram, and populates the first round with player names from the \"Players\" sheet. A custom menu, \"Bracket maker\", allows the user to trigger the `createBracket` function, which generates the bracket after obtaining user authorization. The code then uses loops to manage player distribution and bracket formatting.\n"]]