【问题标题】:google docs spreadsheet asp.net谷歌文档电子表格 asp.net
【发布时间】:2011-07-30 12:09:48
【问题描述】:

我正在使用 .net 的谷歌文档电子表格 API,我想使用 asp.net C# 插入新行谷歌文档我无法做到这一点。

谁能帮帮我??

【问题讨论】:

  • 您应该显示您现在使用的代码 - 提供一些详细信息和任何错误消息。否则将很难为您提供帮助。

标签: asp.net google-spreadsheet-api newrow


【解决方案1】:

如果您确实发布了您已经拥有的代码,那么我们可能会专门为您提供帮助。

根据 Google 开发者指南 (here):

添加一行

要在基于列表的提要中插入新行,首先构造一个新的 ListEntry 并将其 Elements 属性设置为包含行中的单元格。例如,给定表示现有行的 ListEntry,您可能会提示用户输入每列的值,如下所示:

ListEntry newRow = new ListEntry();

foreach (ListEntry.Custom element in existingRow.Elements)
{
  Console.Write("Enter the value of column {0}: ", element.LocalName);
  String elementValue = Console.ReadLine();

  ListEntry.Custom curElement = new ListEntry.Custom();
  curElement.LocalName = element.LocalName;
  curElement.Value = elementValue;

  newRow.Elements.Add(curElement);
}

然后在 ListFeed 中插入新行,如下所示:

ListEntry insertedRow = feed.Insert(newRow) as ListEntry;

电子表格会在基于列表的提要中出现的最后一行之后立即插入新行,也就是说,紧接在第一个完全空白的行之前。此代码相当于向 URL 发送经过身份验证的 POST 请求:

https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full

在 POST 正文中使用相应的 XML 文档。

谢谢。

【讨论】:

  • 我正在尝试输入第一行,但添加的行必须与标题行(或工作表中列标题的值)匹配。但在整个文档中。没有地方提到如何添加标题行?因此,我收到了异常 400 错误请求。在谷歌文档中:row.Elements.Add(new ListEntry.Custom() { LocalName = "Name", Value = "joe" });,但是如何添加这个 localName 标头?
猜你喜欢
  • 2014-07-01
  • 2011-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多