如何使用.NET API从Google电子表格中的单元格中检索超链接?

时间:2013-08-08 17:18:56

标签: .net hyperlink formula google-spreadsheet-api

我正在使用Google Spreadsheet .NET API,我有一个包含超链接的单元格的列。我想通过C#检索单元格的公式。我提到这个与我类似的问题"How can I retrieve the hyperlink from a data cell in google apps script?"。我正在借用picture from the mentioned question来正确显示问题。

我正在使用Google教程中的以下代码:

using System;
using Google.GData.Client;
using Google.GData.Spreadsheets;

namespace MySpreadsheetIntegration
{
  class Program
  {
    static void Main(string[] args)
    {
      SpreadsheetsService service = new SpreadsheetsService("MySpreadsheetIntegration-v1");

      //AUTH

      SpreadsheetQuery query = new SpreadsheetQuery();

      SpreadsheetFeed feed = service.Query(query);

      SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
      Console.WriteLine(spreadsheet.Title.Text);

      WorksheetFeed wsFeed = spreadsheet.Worksheets;
      WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

      CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
      CellFeed cellFeed = service.Query(cellQuery);

      foreach (CellEntry cell in cellFeed.Entries)
      {
        Console.WriteLine(cell.InputValue);
      }
    }
  }
}

cell.InputValue始终为null。我错过了什么,你可以帮忙吗?

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

cell.InputValue将用于输入 到单元格中。它将用作:

cell.InputValue = string;

Google Spreadsheets API的功能非常有限。我的理解是,虽然它可以读取和写入单元格,但其中包含的任何公式或格式(包括超链接)都是API无法实现的。

相关问题