如何使用 Zend GData 创建空电子表格

发布于 2024-11-25 10:05:08 字数 42 浏览 1 评论 0原文

如何使用 Zends GData Library 创建新的空电子表格?

How to create a new, empty spreadsheet using Zends GData Library?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我要还你自由 2024-12-02 10:05:08

根据 Google 文档列表 API,要创建新的空电子表格:请按照< a href="https://developers.google.com/google-apps/documents-list/#creating_a_new_document_or_file_with_metadata_only">创建仅包含元数据的新文档或文件。执行此操作时,请使用类别术语 http://schemas.google.com/docs/2007#spreadsheet

使用 Zend GData 库,它可能看起来像这样:

// Load Zend library
require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Docs');

// Authentication
$client = Zend_Gdata_ClientLogin::getHttpClient('[email protected]', 'sunshine-', Zend_Gdata_Docs::AUTH_SERVICE_NAME);

// Get interface to Documents List API
$docs = new Zend_Gdata_Docs($client);

// Create new document
$data = new Zend_Gdata_Docs_DocumentListEntry();
$data->setCategory(
      array(new Zend_Gdata_App_Extension_Category(
              "http://schemas.google.com/docs/2007#spreadsheet",
              "http://schemas.google.com/g/2005#kind"
)));
$data->setTitle(new Zend_Gdata_App_Extension_Title("My brand new spreadsheet", null));

// Add document to your list
$doc = $docs->insertDocument($data, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);

// Display document ID
print($doc->getId());

According to the Google Documents List API, to create a new, empty spreadsheet: follow the instructions in Creating a new document or file with metadata only. When doing so, use a category term of http://schemas.google.com/docs/2007#spreadsheet.

With Zend GData library, it may look like this:

// Load Zend library
require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Docs');

// Authentication
$client = Zend_Gdata_ClientLogin::getHttpClient('[email protected]', 'sunshine-', Zend_Gdata_Docs::AUTH_SERVICE_NAME);

// Get interface to Documents List API
$docs = new Zend_Gdata_Docs($client);

// Create new document
$data = new Zend_Gdata_Docs_DocumentListEntry();
$data->setCategory(
      array(new Zend_Gdata_App_Extension_Category(
              "http://schemas.google.com/docs/2007#spreadsheet",
              "http://schemas.google.com/g/2005#kind"
)));
$data->setTitle(new Zend_Gdata_App_Extension_Title("My brand new spreadsheet", null));

// Add document to your list
$doc = $docs->insertDocument($data, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);

// Display document ID
print($doc->getId());
你又不是我 2024-12-02 10:05:08

你现在不能这样做。

电子表格数据 API 目前不提供方法
以编程方式创建或删除电子表格。

引用自官方文档

You cannot do this at this moment.

The Spreadsheets data API does not currently provide a way to
programmatically create or delete a spreadsheet.

quote from official documentation

硪扪都還晓 2024-12-02 10:05:08

我是这样做的:

     $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
     $client = Zend_Gdata_ClientLogin::getHttpClient('USERNAME', 'PASSOWRD', $service);
     $docs = new Zend_Gdata_Docs($client);

     // A file I use as a template for this [ based on the extension is the type of document that will be created] 
     // see: http://framework.zend.com/manual/en/zend.gdata.docs.html
     $fileToUpload = 'Rates-Template.xls'; 
     $newDocumentEntry =  $docs->uploadFile($fileToUpload, 'Spreadsheet Title Here',null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);

Here is how I did it:

     $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
     $client = Zend_Gdata_ClientLogin::getHttpClient('USERNAME', 'PASSOWRD', $service);
     $docs = new Zend_Gdata_Docs($client);

     // A file I use as a template for this [ based on the extension is the type of document that will be created] 
     // see: http://framework.zend.com/manual/en/zend.gdata.docs.html
     $fileToUpload = 'Rates-Template.xls'; 
     $newDocumentEntry =  $docs->uploadFile($fileToUpload, 'Spreadsheet Title Here',null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文