id,
        $object -> lastSave,
        $fullJSON,
        $object -> timeWatchM,
        $object -> timeWatchW,
        $object -> timeWatchD,
        $object -> countWatchM,
        $object -> countWatchW,
        $object -> countWatchD];
}
function findRowIndex($id, $data) {
    $rowCounter = -1;
    foreach ($data as $row) {
        $rowCounter ++;
        if($row[0] == $id) {
            return $rowCounter;
        }
    }
    return $rowCounter + 1;
}
$entityBody = '{"lastSave": 0, "timeWatchM": 0, "timeWatchW": 0, "timeWatchD": 0, "countWatchM": 0, "countWatchW": 0, "countWatchD": 0, "id":"test","watches":[{"actions":[]},{"actions":[]},{"actions":[]}]}';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $entityBody = file_get_contents('php://input');
    $entityBodyObject = json_decode($entityBody);
    echo "POST Request received.
";
    if(property_exists($entityBodyObject, "id")) {
        $data = read_xls_file($fileName);
        foreach ($data as $row) {
            echo "new Row: 
";
            foreach ($row as $cell) {
                echo $cell." ";
            }
        }
        $rowIndex = findRowIndex($entityBodyObject->id, $data);
        $data[$rowIndex] = objectToArray($entityBodyObject, $entityBody);
        write_xlsxFile($fileName, $data);
        echo "
Data saved.
";
    }
} else {
    echo "invalid Request.
 Type: ".$_SERVER['REQUEST_METHOD'];
}