PHP | Spreadsheet | Setting a cell value by coordinate
The setCellValue() function is an inbuilt function in PHPSpreadsheet which is used to set the value of a cell in a spreadsheet.
setCellValue( $coordinate, $value )
Parameters: This function accepts two parameters as mentioned above and described below:
- $coordinate: This parameter is used to store the value of the coordinate of the excel sheet.
- $value: This parameter is used to store the value of data which is to be set in an excel sheet.
Return Value: This function returns Object of class PhpOffice\PhpSpreadsheet\Worksheet\Worksheet.
Alternatively, It can be achieved by retrieving the cell object firstly and then set the value. For this purpose, Cell object can be retrieved with the help of getCell() function, and then the value can be set with the help of setValue() function.