gpt4 book ai didi

google-apps-script - 将 html 转换为 Google 文档

转载 作者:行者123 更新时间:2023-12-02 03:20:53 41 4
gpt4 key购买 nike

我有一些像这样的 html:

    var html = '<h1>heading</h1><p>Lorem ipsum dolor sit amet<br>more text</p><ul><<li>Bulleted text</li></ul>'

我想将这个字符串转换为谷歌文档中的富文本。我有什么办法可以做到这一点吗?

最佳答案

例如,从您的代码中,如果您想使用 Google Apps Script 实现它,那么这个示例脚本怎么样?我认为您的情况有几种解决方案。因此,请将其视为其中之一。

当您使用此脚本时,请在 Advanced Google Services 和 API 控制台启用 Drive API。您可以在 here 查看相关信息.

示例脚本:

var html = '<h1>heading</h1><p>Lorem ipsum dolor sit amet<br>more text</p><ul><<li>Bulleted text</li></ul>';
var blob = HtmlService.createHtmlOutput(html).getBlob();
Drive.Files.insert({title: "fileName", mimeType: MimeType.GOOGLE_DOCS}, blob);

备注:

  • 在高级 Google 服务和 API 控制台启用 Drive API 后运行此脚本时,将创建新文档。当您打开文档时,您可以看到从 HTML 转换后的富文本。
  • 这是一个简单的示例脚本。所以请根据您的情况修改它。

引用:

如果这不是您想要的结果,我深表歉意。

关于google-apps-script - 将 html 转换为 Google 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54850715/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com