Created
September 12, 2021 20:54
-
-
Save batFormat/fbc40644f23417035e3813ef4f9d29ac to your computer and use it in GitHub Desktop.
Merge cells in google sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Test { | |
public function test() { | |
$service = new Google_Service_Sheets(GoogleService::getClient()); | |
$spreadsheetId = 'abcdf'; | |
$values = [ | |
["Item", "Cost", "Stocked"], | |
["Wheel", "$20.50", "4"] | |
]; | |
$valueRange = new Google_Service_Sheets_ValueRange([ | |
'values' => $values, | |
]); | |
$conf = [ | |
"valueInputOption" => "RAW", | |
]; | |
$range = "Задачи!A1:C"; | |
$rangeinst = new \Google_Service_Sheets_GridRange(); | |
$rangeinst->setSheetId(0); | |
$rangeinst->setStartRowIndex(0); | |
$rangeinst->setEndRowIndex(11); | |
$rangeinst->setStartColumnIndex(0); | |
$rangeinst->setEndColumnIndex(2); | |
$merge = New Google_Service_Sheets_MergeCellsRequest(); | |
$merge->setMergeType('MERGE_COLUMNS'); | |
$merge->setRange($rangeinst); | |
$requestbody = new \Google_Service_Sheets_Request(); | |
$requestbody->setMergeCells($merge); | |
$requestBatchBody = new \Google_Service_Sheets_BatchUpdateSpreadsheetRequest(); | |
$requestBatchBody->setRequests($requestbody); | |
$result = $service->spreadsheets->batchUpdate($spreadsheetId, $requestBatchBody); | |
dd($result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment