I found out how to fix the problem. I have to take two different variables. One like the above and one with ->setAlign('right'). If I use two different variables, it works:
if (strtoupper($val) == "PRICE") {
$worksheet->writeString($row_pos, $col, $item[$val], $format_pos_data_right);
} else {
$worksheet->writeString($row_pos, $col, $item[$val], $format_pos_data_left);
}