【发布时间】:2023-03-24 23:25:01
【问题描述】:
我有一张表来跟踪大约 1400 个停车位,并且想在边栏中添加单独的搜索。我已经能够通过单击自定义菜单来显示侧边栏。在边栏中,我已经能够重命名它,添加搜索栏,并在栏下方添加搜索和关闭按钮。
我现在需要帮助,一旦用户在搜索栏中输入空格编号并单击搜索,它将获取该空格编号,查看 B 列并从该行收集以下信息并返回到侧边栏以下格式:
- B 列:'返回 B 列信息'
- C 列:'返回 C 列信息'
- D 列:'返回 D 列信息'
- E 列:'返回 E 列信息'
- F 列:'返回 F 列信息'
- G 列:'返回 G 列信息'
- 行号:'返回信息所在的行号'
以下是我现在拥有的代码。
菜单.gs
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Sidebar')
.addItem('Show Sidebar', 'showSidebar')
.addToUi();
}
Sidebar.gs
function showSidebar() {
var html = HtmlService.createHtmlOutputFromFile('index')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle('Individual Space Lookup');
SpreadsheetApp.getUi()
.showSidebar(html);
}
function searchInfo() {
return ('test');
}
index.html
<div>
Search Individual Space: <input type="search" />
<BR>
<input type="button" value="Search"
onclick="google.script.run.onSuccess()" />
<input type="button" value="Close"
onclick="google.script.host.close()" />
<script>
function onSuccess(searchInfo) {
alert('Column B: ' + searchInfoColB
<br>'Column C: ' + searchInfoColC
<br>'Column D: ' + searchInfoColD
<br>'Column E: ' + searchInfoColE
<br>'Column F: ' + searchInfoColF
<br>'Column G: ' + searchInfoColG
<br>'Row Number: ' + searchInfoRowNum
);
}
google.script.run.withSuccessHandler(onSuccess)
.searchInfo();
</script>
</div>
【问题讨论】:
标签: html google-apps-script google-sheets sidebar