标签: google-docs-api

如何使用API​​在新的Google电子表格中创建第一行?

这是我创建电子表格的方式:

DocsService client= new DocsService ("idea");
client.useSsl ();
client.setOAuthCredentials (oauthParameters, new OAuthHmacSha1Signer ());

DocumentListEntry newEntry= new com.google.gdata.data.docs.SpreadsheetEntry ();
newEntry.setTitle (new PlainTextConstruct ("GIdeaDB"));
DocumentListEntry insertedEntry= client.insert (new URL (
  "https://docs.google.com/feeds/default/private/full/?xoauth_requestor_id="+ userEmail), newEntry);
Run Code Online (Sandbox Code Playgroud)

现在我想在其中写下第一行.

但不幸的是,所有的API调用基于这样的事实,即已经存在第一行,因为您插入了名称 - 值对(其中名称是我想要创建的标题). http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html#CreatingTableRecords

我有什么想法可以创建第一行?定义字段名称的那个.

java gwt google-sheets google-docs-api google-spreadsheet-api

6
推荐指数
1
解决办法
6766
查看次数

通过Google Spreadsheet API添加标头

我无法通过Java API将标头(或任何常规数据)插入到新创建的工作表中.插入数据的标准方法是提供标题和值,例如

newEntry.getCustomElements().setValueLocal(header, value2);
Run Code Online (Sandbox Code Playgroud)

这个问题类似于stackoverflow上发布的这个问题:

如何在Google电子表格中添加标题

建议的答案是尝试使用基于单元格的馈送,而不是基于以上示例中的列表.我无法做到这一点,因为对细胞的任何查询或尝试获取细胞饲料似乎都返回0,因为任何细胞中都没有数据要返回...至少这是我认为正在发生的事情......

例如

    public void getCells(){
         cellFeedUrl = worksheetEntry.getCellFeedUrl();
        CellFeed feed;
        try {
            feed = spreadSheetService.getFeed(cellFeedUrl, CellFeed.class);

        for (CellEntry cell : feed.getEntries()) {
          System.out.println(worksheetEntry.getTitle().getPlainText());
          String shortId = cell.getId().substring(cell.getId().lastIndexOf('/') + 1);
          System.out.println(" -- Cell(" + shortId + "/" + cell.getTitle().getPlainText()
              + ") formula(" + cell.getCell().getInputValue() + ") numeric("
              + cell.getCell().getNumericValue() + ") value("
              + cell.getCell().getValue() + ")");
        }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ServiceException e) {
            // TODO …
Run Code Online (Sandbox Code Playgroud)

java google-sheets google-docs-api

6
推荐指数
1
解决办法
1218
查看次数

Google Docs API - 模拟用户文件下载

将Google Docs Java API与Google Apps帐户一起使用,是否可以冒充用户并下载文件?

当我运行下面的程序时,它显然登录到域并模拟用户,因为它检索其中一个文件的详细信息并打印出文件标题.但是,当它尝试下载文件时,会抛出ServiceForbiddenException.

如果Java API无法实现,是否有人知道我的程序是否可以使用Protocol API编写HTTP请求来下载文件?

public class AuthExample {

private static DocsService docService = new DocsService("Auth Example");

public static void main(String[] args)
    throws Exception
{
    String adminUser = args[0];
    String adminPassword = args[1];
    String authToken = args[2];
    String impersonatedUser = args[3];

    loginToDomain(adminUser, adminPassword, authToken);

    URL url = new URL( "https://docs.google.com/feeds/" + impersonatedUser + "/private/full" );
    DocumentListFeed feed = docService.getFeed(url, DocumentListFeed.class);

    DocumentListEntry entry = feed.getEntries().get(0);

    String title = entry.getTitle().getPlainText();
    System.out.println( title );

    String type = entry.getType();
    if …
Run Code Online (Sandbox Code Playgroud)

google-docs google-docs-api google-data-api

6
推荐指数
1
解决办法
742
查看次数

Google文档查看器的API

请参考下面的线谷歌文档列表API组和有人请建议我一个解决方案.

    Hi again Jags,

    Sorry, I missed one thing, you might be able to use the embed link, i.e. that link with rel http://schemas.google.com/docs/2007#embed. That will give you a link to embed the resource.

    Regards


    On Tue, Mar 27, 2012 at 10:59 AM, Ali Afshar wrote:
    Hi Jags,

    Sorry, there is no real API there as such to do what you want to achieve. You should probably export it as a format that you can embed …
Run Code Online (Sandbox Code Playgroud)

google-docs-api

6
推荐指数
1
解决办法
1万
查看次数

在Android中使用Google docs API for OCR

我正在尝试开发一个使用OCR的Android应用程序.应用程序应该能够扫描名片和其他文档来提取内容.

是否可以使用Google Docs Api实现此功能?我该怎么做?

ocr android google-docs-api

6
推荐指数
1
解决办法
2万
查看次数

通过id打开谷歌文档

我要做的是制作模板文档的副本,将附加工作表数据复制到新文件中.我使用doc URL作为id.但是,当我尝试访问该文件时,我收到此错误"文档丢失(可能已被删除?)(第21行)"第21行是

    var templateid = "URL";
    var file = DocumentApp.openById(templateid);        
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议问题是什么?

url google-docs-api google-apps-script

6
推荐指数
1
解决办法
1万
查看次数

上传文件时,Google文档API会返回503服务不可用.有什么变化?

我的应用程序使用了Google Docs API.直到最近,使用HTTP端点的上传工作正常.最近,上传突然开始出错.第一次创建会话(返回可恢复的URL)的调用工作正常,并返回一个可恢复的URL.然后尝试将文件内容发送到可恢复的URL会引发503.

抛出错误的代码的相关部分是这样的:

        URL url = new URL(resumableFileUploadUrl);
        conn = (HttpURLConnection) url.openConnection();
        conn.addRequestProperty("client_id", OAuth2Client.CLIENT_ID);
        conn.addRequestProperty("client_secret", OAuth2Client.CLIENT_SECRET);
        conn.setRequestProperty("Authorization", "OAuth " + GetAuthToken());

        conn.setRequestProperty("X-Upload-Content-Length", String.valueOf(fileContents.length())); //back to 0
        conn.setRequestProperty("X-Upload-Content-Type", "text/xml");
        conn.setRequestProperty("Content-Type", "text/xml");
        conn.setRequestProperty("Content-Length", String.valueOf(fileContents.length()));
        conn.setRequestProperty("Slug", fileName);

        if(isUpdate)
        {
            conn.setRequestProperty("If-Match", "*");
            conn.setRequestMethod("PUT");
        }
        else
        {
            conn.setRequestMethod("POST");
        }

        conn.setRequestProperty("GData-Version", "3.0");
        conn.setRequestProperty("User-Agent", "GPSLogger for Android");


        conn.setUseCaches(false);
        conn.setDoInput(true);
        conn.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream(
                conn.getOutputStream());
        wr.writeBytes(fileContents);
        wr.flush();
        wr.close();

        int code = conn.getResponseCode();
        newLocation = conn.getHeaderField("location");
Run Code Online (Sandbox Code Playgroud)

上述代码既用于创建会话以获取可恢复的URL,也将文件内容发布到可恢复的URL.

这是一部分这个 Android的活动.我包含了原始活动的链接,因为通过简单地克隆存储库可能很容易重现问题.该守则一直保持不变.

最近有什么改变会导致这种情况吗?

我想避免现在使用Google Drive的API,因为我没有更改任何代码,并且在该领域的一些其他应用程序中使用了相同的代码.

java android google-docs-api

6
推荐指数
1
解决办法
887
查看次数

Google Drive API获取文件编辑网址

自2015年4月20日起,Google Documents API v3.0已弃用,并且在此日期之后将不再运行功能.因此,使用此API的任何人都必须切换为使用Google Drive API.

我已将Google Drive API集成到我的PHP应用程序中,但我无法找到如何为我创建或上传的文件获取EDIT网址.以前在上传文件后的Google Documents API中,响应会返回一个编辑网址,该编辑网址将是编辑该文件的直接网址.

我使用的是一个服务帐户,该帐户使用我的Google开发者帐户生成的密钥,网址https://console.developers.google.com.这意味着我的应用程序代表开发人员帐户为我创建的服务帐户拨打电话.Drive UI服务帐户无法通过云端硬盘用户界面访问,因为作为用户,您无法像使用个人Google帐户一样登录该帐户.

我所做的是与我的个人帐户共享我上传或创建的文档,并且通话中的url google返回名为"alternateLink",格式如下:https: //docs.google.com/file/ d/0B0nkjw07ekP9LUpuZG4tOHcxdkE /编辑?USP = drivesdk

但是,当我登录到我共享上述文件的帐户时,它只会转到查看者,而不是"Google文档编辑器"

如何获取Google Drive API的文件编辑链接?

google-docs google-docs-api google-drive-api google-api-php-client

6
推荐指数
1
解决办法
2589
查看次数

强制打开Goog​​le文档而不显示“打印版式”视图

在Google文档中编写指南,并以只读方式与其他人共享,非常有用。但是,即使在不使用“打印布局”选项(“查看”菜单下的第一个切换选项)进行格式化的情况下,每个打开文档的查看者都可以在“打印布局”中看到它,即在每个分页符之前有半空的页面。这很烦人。

当只读查看器打开Goog​​le文档时,是否有任何方法可以将打印布局默认设置为关闭?我希望通过以下两种方式:

  • 通过URL参数,以便我共享的链接确定文档将以关闭的打印版式打开;

  • 在Google Apps脚本中,类似于function onOpen(){ DocumentApp.getActiveDocument().setPrintLayout(false); } setPrintLayout()目前似乎不存在)

我对网络浏览器版本和移动应用程序都非常感兴趣(尽管更少)。

有一个类似的问题在那里(有截图)。

当关闭只读Google文档中的“打印版式”还无法进行时(现在,虽然只能手动进行),但有一段讨论可以追溯到以前。

google-docs google-docs-api

6
推荐指数
0
解决办法
959
查看次数

无法在谷歌文档查看器中嵌入 .doc、docx 文件

我有将文件嵌入页面并在 Google Docs Viewer 中打开的代码。但到目前为止,当我想打开 .doc 或 docx 文件时,我得到“无预览可用”,但在打开 PDF 文件时可以正确打开。再次提示我不是在 Google Docs 中打开文件而是下载文件而不是在浏览器上查看它。

这是我的代码:

<a href="sample.doc"  class="embed"><h2>sample.doc</h2><button >view document</button></a>
<script>
    $(document).ready(function() {
      $('a.embed').gdocsViewer({width:740,height:742});
      $('#embedURL').gdocsViewer();
    });
</script>
Run Code Online (Sandbox Code Playgroud)

这是我的 jQuery 插件:

(function($){
    $.fn.gdocsViewer = function(options) {

        var settings = {
            width  : '600',
            height : '700'
        };

        if (options) { 
            $.extend(settings, options);
        }

        return this.each(function() {
            var file = $(this).attr('href');
            var ext = file.substring(file.lastIndexOf('.') + 1);

            if (/^(tiff|doc|ppt|pps|pdf|docx)$/.test(ext)) {
                $(this).after(function () {
                    var id = $(this).attr('id');
                    var gdvId = (typeof id …
Run Code Online (Sandbox Code Playgroud)

php jquery google-docs-api

5
推荐指数
2
解决办法
2万
查看次数