I am trying to upload a local CSV file to Google Drive and display it as a Google spreadsheet. However, when I go to my Google Drive and click on the link to my file, I can download it, and not view it as a spreadsheet. I tried using ?convert=true , but the file does not convert. I also tried to use application/vnd.google-apps.spreadsheet as the mime type, but noting the changes or getting a 400 Bad request response.
When I right-click the file, I can open it using Google Spreadsheets, which then displays the file correctly. I cannot find anything about this in the current documentation on Google, and a google search will not help much.
What I have done so far is creating a new empty Google spreadsheet and trying to populate it with my CSV file, but this gives me a 500 Internal Error .
$file = new Google_DriveFile(); $file->setTitle('Exported data from ' . $this->event->title); $file->setDescription('Exported data from ' . $this->event->title); $file->setMimeType( 'text/csv' ); try { $createdFile = $this->drive->files->insert($file, array( 'data' => $data, 'mimeType' => 'application/vnd.google-apps.spreadsheet' ), array('convert'=>true));
I looked at the API for Google Drive, but did not find anything useful. I am wondering if I should use the Google Spreadsheets API or the Google Drive API, which will be used exclusively?
Thanks a lot in advance, Waldemar
source share