Open rahul3883 opened 8 years ago
here is my code
$client = new Google_Client(); $client->setAuthConfig('My Project-2f9fd22b3c4f.json'); $client->addScope("https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.scripts", "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.apps.readonly"); $token = $client->fetchAccessTokenWithAssertion(); $driveService = new Google_Service_Drive($client); $fileMetadata = new Google_Service_Drive_DriveFile(array( 'name' => 'Project plan', 'mimeType' => 'application/vnd.google-apps.spreadsheet')); $file = $driveService->files->create($fileMetadata, array( 'fields' => 'id')); $fileId = $file->id; use Google\Spreadsheet\DefaultServiceRequest; use Google\Spreadsheet\ServiceRequestFactory; $serviceRequest = new DefaultServiceRequest($token["access_token"]); ServiceRequestFactory::setInstance($serviceRequest); $spreadsheetTitle = 'newWorksheet'; $spreadsheetService = new Google\Spreadsheet\SpreadsheetService(); $worksheetFeed = $spreadsheetService->getPublicSpreadsheet($fileId); $spreadsheetFeed = $spreadsheetService->getSpreadsheetFeed(); $spreadsheet = $spreadsheetFeed->getEntries(); $spreadsheet->addWorksheet('worksheet11', 50, 20); $cellFeed = $spreadsheet->getCellFeed(); $cellFeed->editCell(1,1, "name"); $cellFeed->editCell(1,2, "age"); $listFeed = $worksheet->getListFeed(); $listFeed->insert(["name" => "Someone", "age" => 25]);
here is my code