0

I try to use Google Spreadsheets API and Google Documents List API, butI can't understand how to add new generated form scratch spreadsheet.

I find how to add empty spreadsheet (C#):

DocumentEntry entry = new DocumentEntry();
entry.Title.Text = title;
entry.Categories.Add(DocumentEntry.SPREADSHEET_CATEGORY);
DocumentEntry newEntry = documentsService.Insert(DocumentsListQuery.documentsBaseUri, entry);

But how to fill it by data? May be with updating cells with a batch request. But WorksheetEntry is needed for it. There is no way to get WorksheetEntry from DocumentEntry (it's only possible by worksheet searching in SpreadSheetFeed::Entries)

Is there any normal way to upload new generated spreadsheet?

4

1 回答 1

0

您可以用数据填充电子表格,但整个电子表格将被覆盖。我没有找到一种方法来更新电子表格的一部分而不会导致显着的性能损失。

下面的代码假设 documentService 是 DocumentsService,entry 是 DocumentEntry。

var factory = (GDataRequestFactory)documentService.RequestFactory;
factory.CustomHeaders.Add("If-Match: " + entry.Etag);

var mediaUri = new Uri(entry.MediaUri.ToString());

documentService.Update(mediaUri, "your-csv-string-here", "text/csv", entry.Title.Text);
于 2013-12-19T06:04:24.853 回答