Are you looking for merge cells snippets?
Below are the different snippets you can use to merge cells with PhpSpreadsheet or Google Sheets API PHP Client.
PhpSpreadsheet (Excel Files)
// Merge cells from A1 to D5
$sheet->mergeCells('A1:D5');
Google Sheets API PHP Client
$requests = [
new Google_Service_Sheets_Request([
'mergeCells' => [
'range' => ['startRowIndex'=> 1, 'endRowIndex'=> 3, 'startColumnIndex'=> 1, 'endColumnIndex'=> 3],
'mergeType'=> 'MERGE_ALL',
],
])
];
$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
'requests' => $requests
]);
$response = $service->spreadsheets->batchUpdate($spreadsheetId, $batchUpdateRequest);
[you_might_be_interested ids=”55,767″]
Leave a Reply