有没有办法使用应用程序脚本将 html 文本保存到谷歌驱动器中的文件?
- 作者: 小小鸟一
- 来源: 51数据库
- 2022-10-26
问题描述
有没有办法使用应用程序脚本将 html 文本保存到谷歌驱动器中的文件?我的应用程序发回一个 html 字符串,我想将其作为 .html 文件保存到驱动器中,就像我将 HTML 文件上传到驱动器一样.然后,我打算将此 .html 文件作为 google doc 打开,这会将其转换为 doc 格式.我已经手动尝试过这个过程,效果很好.只需要在脚本中完成.
Is there a way to save html text to a file in google drive using apps script? My app sends back an html string, which I want to save as an .html file into drive, as if I'd uploaded an HTML file to drive. I then intend on opening this .html file as a google doc, which will convert it to a doc format. I've tried this procedure manually, and it works well. Just need to do it in a script.
更重要的是,我想要一种直接将 HTML 转换为谷歌文档的方法.
More to the point, I'd love a direct way to convert HTML into a google doc.
推荐答案
var url = 'YOUR PAGE;
var p = SitesApp.getPageByUrl(url);
var html = p.getHtmlContent();
var blob = DriveApp.createFile('dummy',html, 'text/html').getBlob();
var resource = {
title: 'YOUR FILE NAME',
convert: true,
mimeType: 'application/vnd.google-apps.document'
};
Drive.Files.insert(resource,blob);
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
