访问使用谷歌数据API与C#谷歌小号preadsheets
我在谷歌中的小号preadsheets一些信息作为一个单一的表。
有没有什么办法由我可以通过提供谷歌凭据和s preadsheet地址读取.NET此信息。是否有可能使用谷歌数据API。
最终,我需要从谷歌小号preadsheet在一个DataTable中的信息。
我该怎么办呢?如果有人试图它,请分享一些信息。
I'm having some information in Google Spreadsheets as a single sheet. Is there any way by which I can read this information from .NET by providing the google credentials and spreadsheet address. Is it possible using Google Data APIs. Ultimately I need to get the information from Google spreadsheet in a DataTable. How can I do it? If anyone has attempted it, pls share some information.
按照 .NET用户指南:
下载 .NET客户端库:
添加以下using语句:
Add these using statements:
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Spreadsheets;
身份验证:
SpreadsheetsService myService = new SpreadsheetsService("exampleCo-exampleApp-1");
myService.setUserCredentials("jo@gmail.com", "mypassword");
获取小号preadsheets的列表:
Get a list of spreadsheets:
SpreadsheetQuery query = new SpreadsheetQuery();
SpreadsheetFeed feed = myService.Query(query);
Console.WriteLine("Your spreadsheets: ");
foreach (SpreadsheetEntry entry in feed.Entries)
{
Console.WriteLine(entry.Title.Text);
}
由于你已经获取一台S preadsheetEntry,你可以得到所有这一切工作表的表S preadsheet如下:
Given a SpreadsheetEntry you've already retrieved, you can get a list of all worksheets in this spreadsheet as follows:
AtomLink link = entry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
WorksheetQuery query = new WorksheetQuery(link.HRef.ToString());
WorksheetFeed feed = service.Query(query);
foreach (WorksheetEntry worksheet in feed.Entries)
{
Console.WriteLine(worksheet.Title.Text);
}
和获得基于细胞饲料:
AtomLink cellFeedLink = worksheetentry.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
CellQuery query = new CellQuery(cellFeedLink.HRef.ToString());
CellFeed feed = service.Query(query);
Console.WriteLine("Cells in this worksheet:");
foreach (CellEntry curCell in feed.Entries)
{
Console.WriteLine("Row {0}, column {1}: {2}", curCell.Cell.Row,
curCell.Cell.Column, curCell.Cell.Value);
}