我想使用Google Docs API将页眉和页脚添加到现有的 Google Docs 文件。
查看documents.batchUpdate(链接),我们可以插入文本、替换文本、添加图像和表格等,方法是在 JSON 有效负载中使用 等对象提及它们replaceAllText,insertText但我找不到任何插入页眉和页脚的方法。
问题1:如何添加页眉和页脚?
问题2:如何为文档首页添加不同的页眉/页脚?
如果不可能,我们将非常感谢建议使用任何其他 API 或方法(例如使用 MS Word)。先感谢您。
我有一个 Google 文档,其中包含一张图像。我发现图像objectId如下所述https://developers.google.com/docs/api/reference/rest/v1/InlineObject但我无法理解如何获取该图像的网址。我尝试在云端硬盘中搜索此内容objectId,但它返回File not found。
有任何想法吗 ?
更新
正如 @Tanaike 所指出的,图像信息包含在 中result.inlineObjects,而不是直接包含在段落中。
我需要一个示例,说明如何通过 API 使用 Google 文档中的现有文本修改现有文档。文档只展示了如何插入和删除文本,但没有展示如何更新。一直在网上疯狂地寻找示例或如何做到这一点的方向,但没有运气。
我使用此链接来读取/获取 Google 文档文档的数据。
注意:出于安全原因,我更改了文档 ID 和 API 密钥。
我使用的网址
https://docs.googleapis.com/v1/documents/1oGPxB3BFf9XSAfe23lqY7OzYkn9_xvXaOQCGjBZEHmS4RSr21Y?key=AIzaSyDk5yXM8zFfg7KIgercswedLYD1bZO6zBue2tO0fk
Run Code Online (Sandbox Code Playgroud)
我得到的错误
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Run Code Online (Sandbox Code Playgroud) 我想将google 文档集成到网络应用程序(Angular 10)中以进行预览、编辑和保存。
我的服务器上存储有文档。我想使用存储在我的服务器上的谷歌文档预览文档(它可以存储在 Amazon S3 或 Azure 等)。
我想使用谷歌文档编辑该文档并将其保存回我的服务器(用户使用谷歌凭据登录并获得所有权限)。
我知道这一点: https: //docs.google.com/a/[DOMINIO]/viewer?url=[FILE_URL],但它用于预览,文件大小限制为 25 MB。
基本上我需要集成谷歌文档以在我的网络应用程序中预览、编辑和保存文档。
我想通过 Microsoft Office 365(需订阅)实现相同的功能。
如何实现这一目标?
google-docs google-docs-api google-document-viewer office365api angular
我遇到一个实施问题,需要一些帮助:
我正在构建一个 Google Docs 集成,其中涉及以编程方式创建一个表,然后通过记录数组进行映射,以将这些记录的数据添加到表单元格中。我可以创建一个空白表并找到要插入数据的每个单元格的起始索引,但是当我尝试使用insertText文档中的请求并将文本放置在特定单元格中时,出现以下错误:
“无效的请求[1].insertText:插入索引必须位于现有段落的边界内。您仍然可以通过插入新行来创建新段落。”
我尝试过以下方法
'\n'到单元格的起始索引处这是我尝试的最后一个实现:
(对于上下文,我的目标是过滤项目数组,为每个项目创建一个表,然后为该项目对象中的每个子项目都有一个表行,其中相关数据将位于标题 1、2 和 3 下,但现在我很高兴将表格和标题放在正确的位置)
var requests = []
await Promise.all(
items.map(async (item) => {
let subitems = []
subitems = item.subitems.filter((subitem) => subitem.selected)
//Create table api call
await docs.documents
.batchUpdate({
documentId: newDoc.data.documentId,
resource: {
requests: [
{
insertTable: {
columns: 3,
rows: item.subitems.length + 1,
endOfSegmentLocation: { segmentId: '' },
},
},
],
},
})
.then((res) …Run Code Online (Sandbox Code Playgroud) 是否可以使用PHP从Google Docs电子表格中提取行?
在SQL中我会使用类似的东西:
SELECT * FROM table WHERE field = 'value' LIMIT 1
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?我听说你应该使用'Zend'框架,但我也无法解决这个问题.任何帮助,将不胜感激
php zend-framework google-docs google-sheets google-docs-api
我已经跟踪了整个API的文档列表(用于创建spreadhseet)和电子表格(用于创建工作表和添加行).但是,我可以在创建后向spreadhseet添加工作表,但是当我尝试添加行时,我会收到错误消息:请求执行失败:https://spreadsheets.google.com/feeds/list/ tj0pIc6qpEB2LtZY9mwfT-A/OD6 /私营/全
我已经提到了所有OAuth范围和所需的凭据,但无法解决此异常.剩下的工作正常,比如创建谷歌电子表格和添加工作表.我只是复制粘贴谷歌代码.
// setUp the confirguration for OAuth 2.0
string clientID = "********.apps.googleusercontent.com";
string clientSecret = "*******************";
string scope = "https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/";
string redirectURI = "urn:***:wg:oauth:2.0:oob";
// setup the OAuth 2.0 object
OAuth2Parameters parameters = new OAuth2Parameters(); // to hold all the parameters
parameters.ClientId = clientID; // setup the clientID
parameters.ClientSecret = clientSecret; // setup the clientSecret
parameters.RedirectUri=redirectURI; // setup the redirectURI
//setup the authurization URL
parameters.Scope = scope; // set the scope …Run Code Online (Sandbox Code Playgroud) c# google-docs-api google-spreadsheet-api google-cloud-storage google-drive-api
我想编写一个复制模板(仅包含容器绑定脚本)的Google Docs脚本,并附加用户选择的另一个文档的内容.我怎么做到这一点?我已经有办法选择文件(模板有一个静态ID),但想办法将文档的所有内容(包括inlineImages和hyperLinks)复制到我的新文档中.
我按照此示例访问Google表格API:
https://developers.google.com/sheets/api/quickstart/nodejs
在示例代码中,以下方法用于获取新的oauth令牌.
function getNewToken(oauth2Client, callback) {
var authUrl = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: SCOPES
});
console.log('Authorize this app by visiting this url: ', authUrl);
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter the code from that page here: ', function(code) {
rl.close();
oauth2Client.getToken(code, function(err, token) {
if (err) {
console.log('Error while trying to retrieve access token', err);
return;
}
oauth2Client.credentials = token;
storeToken(token);
callback(oauth2Client);
});
});
}
Run Code Online (Sandbox Code Playgroud)
这在我的本地计算机上工作正常(在终端中按提示手动访问页面,并在命令行中输入代码).但这似乎不切实际,并不适用于Heroku.有没有办法自动化这个?也许通过在nodeJS应用程序中获取URL(和令牌)并以某种方式存储它?
提前致谢.
google-docs-api ×10
google-docs ×4
google-api ×3
node.js ×2
php ×2
angular ×1
c# ×1
copy ×1
google-oauth ×1
heroku ×1
javascript ×1
office365api ×1