Cannot automatically convert xlsx to google spreadsheet during API loading

I am trying to get a Google spreadsheet created using a PHP script. Since there seems to be no native PHP API for creating spreadsheets (it can only find Java and .NET), I figured that the easiest way would be to create XLSX and convert it to a Google spreadsheet.

File upload works fine:

$mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
$file = new Google_DriveFile();
$file->setTitle('My Spreadsheet');
$file->setMimeType($mime);

$data = file_get_contents('my_spreadsheet.xlsx');
$createdFile = $service->files->insert($file, array(
    'data' => $data,
    'mimeType' => $mime,
    'convert' => true,
));

However, when it appears in Google Drive, it is a regular Excel file. I have to right-click it on the web interface of Google Drive and select "Open in Google Sheets" before converting it (but the conversion does not contain errors).

How can I force a file conversion?

+3
source share
2 answers

, api google spreadsheets api, https. php, zend, : http://framework.zend.com/manual/1.12/en/zend.gdata.spreadsheets.html

0

Google , . Google PHP SDK, .

https://developers.google.com/drive/v3/web/manage-uploads#importing_to_google_docs_types_wzxhzdk18wzxhzdk19

, , $mime - , application/vnd.google-apps.spreadsheet, Google.

0

All Articles