I have to write 3 columns in google sheet using v4 api in php
$range = $sheetName;
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();
$lastRow = count($values);
$rowIndex = $lastRow;
$columnIndex = 0;
$requests = array();
$requests[] = new Google_Service_Sheets_Request(array(
'updateCells' => array(
'start' => array(
'sheetId' => $sheetId,
'rowIndex' => $rowIndex,
'columnIndex' => $columnIndex
),
'rows' => array(
array(
'values' => array(
array(
'userEnteredValue' => array('numberValue' => '111111'),
'userEnteredFormat' => array('backgroundColor' => array('red'=>1, 'green'=>0.94, 'blue'=>0.8))
),
array(
'userEnteredValue' => array('stringValue' => 'aaaaaaaaa'),
'userEnteredFormat' => array('backgroundColor' => array('red'=>1, 'green'=>0.94, 'blue'=>0.8))
),
array(
'userEnteredValue' => array('numberValue' => '2015-05-05'),
'userEnteredFormat' => array('numberFormat' => array('type'=>'DATE', 'pattern'=>'yyyy-mm-dd'), 'backgroundColor' => array('red'=>1, 'green'=>0.94, 'blue'=>0.8))
)
)
)
),
'fields' => 'userEnteredValue,userEnteredFormat.backgroundColor'
)
));
$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array(
'requests' => $requests
));
try {
$service->spreadsheets->batchUpdate($spreadsheetId, $batchUpdateRequest);
} catch(Exception $e) {
print_R($e);
}
I am using above code to do the task, the only problem I am facing is that I am getting an error while inserting date.
I read that datetimerenderoption is to be used for inserting the date but I am not getting how to do it.