S
S
StreetRacer2017-11-12 14:59:55
Google
StreetRacer, 2017-11-12 14:59:55

How to specify additional data in Google Drive API export options?

There is a PHP code that uploads an Excel spreadsheet to Google Drive and then exports it to PDF. BUT the table is initially in a horizontal orientation, but is unloaded in a vertical one. + visible grid lines (not cell borders) and large indents on all sides. Is it possible to somehow add parameters in the export request that unload the PDF with a horizontal orientation, so that the grid lines would not be visible and reduce the indents?
Here is the code itself:

$client = new Google_Client();
        if ($credentials_file = checkServiceAccountCredentialsFile()) {
          $client->setAuthConfig($credentials_file);
        } elseif (getenv('GOOGLE_APPLICATION_CREDENTIALS')) {
          $client->useApplicationDefaultCredentials();
        } else {
          echo missingServiceAccountDetailsWarning();
          return;
        }
        $client->setApplicationName("Client_Library_Examples");
        $client->setScopes(['https://www.googleapis.com/auth/drive']);

        $service = new Google_Service_Drive($client);
        
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
        
        $objWriter->save(__DIR__ .'/files/uch_plan/xls/'.$plan_info['plan_info']['name_group'].'.xls');
        
        $fileMetadata = new Google_Service_Drive_DriveFile(array(
          'name' => 'My Report',
          'mimeType' => 'application/vnd.google-apps.spreadsheet'));
        $content = file_get_contents(__DIR__ .'/files/uch_plan/xls/'.$plan_info['plan_info']['name_group'].'.xls');
        $file = $service->files->create($fileMetadata, array(
          'data' => $content,
          'mimeType' => 'application/vnd.ms-excel',
          'uploadType' => 'multipart',
          'fields' => 'id'));
          
        $response = $service->files->export($file->id, 'application/pdf', array(
          'alt' => 'media'));
        $content = $response->getBody()->getContents();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2017-11-12
@dimonchik2013

freelansim.ru
or play with parameters

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question