英文:
Is it possible to create two web apps for one Google Spreadsheets?
问题
I just started learning Google Scripts 3 days ago and was tasked to create a data entry program. I am trying to create a data entry program where inputting the data in the web app will automatically log the data inputted in the Google Spreadsheets. I have successfully created one but I need to create another one for a different type of data but I also need it to be in the same sheet.
我三天前才开始学习Google Scripts,并被要求创建一个数据输入程序。我试图创建一个数据输入程序,在Web应用中输入的数据将自动记录在Google电子表格中。我已经成功创建了一个,但我需要再创建一个用于不同类型的数据,但它也需要在同一个工作表中。
I have tried creating my Index.html as the homepage with two buttons which should link to the other two htmls I have created but using <a href="forms1.html"></a> doesn't seem to be working as it just tells me that the file does not exist or cannot be accessed. I have looked into some references but I cannot understand some of the important parts or does not explain much.
我尝试将Index.html创建为首页,其中包含两个按钮,应该链接到我创建的另外两个HTML文件,但使用<a href="forms1.html"></a> 似乎不起作用,因为它告诉我文件不存在或无法访问。我查阅了一些参考资料,但无法理解其中的一些重要部分,或者解释不够详细。
References:
Where I Learned Google App Scripts
How to use google script web app with multiple pages in google site?
英文:
I just started learning Google Scripts 3 days ago and was tasked to create a data entry program. I am trying to create a data entry program where inputting the data in the web app will automatically log the data inputted in the Google Spreadsheets. I have successfully created one but I need to create another one for a different type of data but I also need it to be in the same sheet.
I have tried creating my Index.html as the homepage with two buttons which should link to the other two htmls I have created but using <a href="forms1.html"></a> doesn't seem to be working as it just tells me that the file does not exist or cannot be accessed. I have looked into some references but I cannot understand some of the important parts or does not explain much.
references:
Where I Learned Google App Scripts
How to use google script web app with multiple pages in google site?
答案1
得分: 0
是的,这是可能的。一个项目只能有一个 doGet
或 doPost
函数。因此,在一个项目中,您只能拥有一个 Web 应用程序。然而,您可以将多个项目绑定到一个电子表格。在旧的编辑器中,这很容易,只需转到“文件 > 新建项目”。但是,在新的编辑器中,似乎无法手动完成此操作。不过,您可以使用 Apps Script API 或该 API 周围的包装器(即 [tag:clasp])来完成这个操作。
在一个新文件夹中,创建项目
clasp create --parentId 电子表格的ID
然后转到另一个文件夹,并使用相同的父 ID 执行相同的命令。如果一切顺利,您将拥有两个独立的项目与同一电子表格绑定。现在,您可以拥有两个 doGet
函数,因此可以拥有两个 Web 应用程序。在这个初始步骤之后,您不再需要使用 clasp/终端,但如果使用它,将会很有帮助。
英文:
Yes, it is possible. One project can have only one doGet
or doPost
function. Therefore, in one project, you can only have one web app. However, you can have more than one project bound to a spreadsheet. This used to be easy in the old editor, where you just had to go to File > New Project. But, with the new editor, this doesn't seem to be possible manually. You can however do it with Apps script api or a wrapper around that api, namely [tag:clasp].
In a new folder, create the project
clasp create --parentId ID_OF_THE_SPREADSHEET
Then go to another folder and do the same command with the same parent id. If that goes well, you'll have two independent projects bound to the same spreadsheet. Now, you can have two doGet
and therefore have two webapps. You don't need clasp/terminal anymore, after this initial step, but it'll help a lot, if you use it though.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论