我知道从 Google Sheets 电子表格读取 JSON 的 URL 格式,如下所示:
https://spreadsheets.google.com/feeds/cells/[sheet_id]/[sheet_number]/public/basic?alt=json
Run Code Online (Sandbox Code Playgroud)
是否有类似的 URL 格式可以从 Google Docs 文档读取 JSON 数据?
我从 Google Apps 脚本开始并尝试创建文件(Google Doc)的副本,然后替换复制文档中的文本并将其转换为 PDF。
该功能工作正常,但替换的文本不会出现在 PDF 文件中,而是出现在复制的文件(我替换的位置)中。
我读到了saveandclose()在函数完成弹出之前保存更改并关闭文档(复制)的方法。但好像没有这个方法。我真的很感谢你的帮助。谢谢。
function replaceconvert() {
var cdoc = DriveApp.getFileById('iddocument').makeCopy('filename321');
var iddoc = cdoc.getId();
var doc = DocumentApp.openById(iddoc);
doc.getBody().replaceText('nombre', 'Juan Perez');
var doc_repl = DriveApp.getFileById(iddoc);
var blob = doc_repl.getAs(MimeType.PDF);
DriveApp.getFolderById(idfolder).createFile(doc1)
}
Run Code Online (Sandbox Code Playgroud) google-docs export-to-pdf google-apps-script google-drive-api
希望我能就此得到一些建议。我正在使用脚本自动创建文档,其中数据来自现有的谷歌文档。在使用链接表失败后,我尝试在文档中由搜索文本标识的点插入表格。
例如,我会在文档中搜索 TABLE1HERE 并将其替换为[[Heading,Data],[Heading2,MoreData]]. 我尝试了下面的代码和许多变体,但没有成功。任何指点都会很棒。
function updateTablesTEST(searchText,replacementTable){
var document = DocumentApp.getActiveDocument();
var documentBody = document.getBody();
var textLocation;
var newPosition;
var textChild;
textLocation = documentBody.findText(searchText).getElement();
textChild = textLocation.getParent().getChildIndex(textLocation);
documentBody.insertTable(textChild+1, replacementTable);
}
Run Code Online (Sandbox Code Playgroud) 请注意,每个单元格内都有不同的颜色、不同的背景和字体样式。我可以创建一个这样的表:
var cells = [
['Row 1, Cell 1', 'Row 1, Cell 2'],
['Row 2, Cell 1', 'Row 2, Cell 2']
];
// Build a table from the array.
body.appendTable(cells);
Run Code Online (Sandbox Code Playgroud)
如何将格式应用于每个单独的单元格以及指定的文本范围内?有一种方法可以设置单元格的背景,但它设置的是整个单元格的背景而不是单元格的一部分。
Windows 10,使用 git 2.30.0.windows.2 和 git bash。
我一直在跟踪存储库中的更改,该存储库也是 Google Drive 文件夹,因为尽管这可能会导致很多问题,但这是将我的代码放入学校集群并满足我的非 git 实验室伙伴同步需求的唯一方法。以前,git 可以很好地跟踪我的存储库中的 .gdoc 文件,但大约三周前 git 开始给我提供以下错误。
$ git add -A
error: Notes/Conservation Designations.gdoc: failed to insert into database
error: unable to index file 'Notes/Conservation Designations.gdoc'
fatal: updating files failed
Run Code Online (Sandbox Code Playgroud)
此外,在 git status 中,某些文件同时显示为已删除和未跟踪。起初我以为是gdoc文件,但仔细想想,实际上很多文件都发生了这种情况,但非gdoc文件可以暂存。当我运行时git add -A --ignore-errors; git status,这是输出。在“要提交的更改”部分中,您可以看到有多个 .gdoc 文件被列为已删除,然后这些文件在输出末尾也被列为“未跟踪” git status。
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: …Run Code Online (Sandbox Code Playgroud) 我刚刚浏览了一篇Google App Engine文章,该文章在某些网址中使用了有趣的向后"P"字符(看近第一个代码框的顶部).你知道你的高中英语老师用来标记新段落的字符(我已经学会了,感谢维基百科,被称为"pilcrow").
我从来没有在URL中看到过这个.那是哪个呢?
python的新手,写了大约一个小时.谷歌docs api和例子很棒.我可以连接和创建文件等.我想将我的所有文件备份到谷歌驱动器,所以尝试使用os.walk并遇到持续缩进错误,我不明白.
#!/usr/bin/python
import httplib2
import pprint
from apiclient.discovery import build
from apiclient.http import MediaFileUpload
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.client import Credentials
import os
import sys
rootdir = sys.argv[1]
CLIENT_ID = 'MYCLIENT ID'
CLIENT_SECRET = 'MY SECRET ID'
OAUTH_SCOPE = 'https://www.googleapis.com/auth/drive'
# Redirect URI for installed apps
REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob'
json_creds = open('backup_credentials.json', 'r').read()
credentials = Credentials.new_from_json(json_creds)
#
# Create an httplib2.Http object and authorize it with our credentials
http = httplib2.Http()
http = credentials.authorize(http)
drive_service = …Run Code Online (Sandbox Code Playgroud) 一直试图从 docs.google.com 获取 favicon / tabicon 没有运气。已经尝试过以下......
http://docs.google.com/favicon.ico
https://docs.google.com/favicon.ico
docs.google.com/favicon.ico
https://plus.google.com/_/favicon?domain=docs.google.com
http://getfavicon.appspot.com/http://docs.google.com/docsgoogle.com.ico
Run Code Online (Sandbox Code Playgroud)
还有其他建议吗?
[添加]
经过一些调查,由于 google docs 登录/身份验证,这看起来可能不起作用。
我正在尝试使用PHP解析Google Docs中的XLS文件.当我手动下载文件然后将其上传到服务器时它工作正常,但是当我使用PHP将完全相同的XLS文件直接保存到服务器时,而不是获取XLS中的所有数据,响应是:
<b>DOM ELEMENT: </b>HTML<br /><b>ATTRIBUTE: </b>lang => en<br /><b>DOM ELEMENT: </b>HEAD<br /><b>DOM ELEMENT: </b>META<br /><b>ATTRIBUTE: </b>charset => utf-8<br /><b>DOM ELEMENT: </b>META<br /><b>ATTRIBUTE: </b>content => width=300, initial-scale=1<br /><b>ATTRIBUTE: </b>name => viewport<br /><b>DOM ELEMENT: </b>META<br /><b>ATTRIBUTE: </b>name => description<br /><b>ATTRIBUTE: </b>content => Create a new spreadsheet and edit with others at the same time -- from your computer, phone or tablet. Get stuff done with or without an internet connection. Use Sheets to edit Excel files. Free from Google.<br /><b>DOM ELEMENT: …Run Code Online (Sandbox Code Playgroud) 我想知道是否有办法使用Python写入谷歌电子表格.找到了python-gdata-client库,安装了所有依赖项.使用下面的代码,但它不起作用
import time
import gdata.spreadsheet.service
email = 'email@gmail.com'
password = 'pwd'
weight = '180'
# Find this value in the url with 'key=XXX' and copy XXX below
spreadsheet_key = 'pRoiw3us3wh1FyEip46wYtW'
# All spreadsheets have worksheets. I think worksheet #1 by default always
# has a value of 'od6'
worksheet_id = 'Sheet1'
spr_client = gdata.spreadsheet.service.SpreadsheetsService()
spr_client.email = email
spr_client.password = password
spr_client.source = 'Example Spreadsheet Writing Application'
spr_client.ProgrammaticLogin()
# Prepare the dictionary to write
dict = {}
dict['date'] = …Run Code Online (Sandbox Code Playgroud) google-docs ×10
python ×2
api ×1
favicon ×1
git ×1
javascript ×1
php ×1
python-2.7 ×1
url ×1
xls ×1