Skip to content

Set cell value with condition #2460

Answered by MarkBaker
TTutorials asked this question in Q&A
Discussion options

You must be logged in to vote

Use a formula perhaps?

$worksheet->setCellValue('B1', '=IF(A1="bar", "foo", "not foo")');

Otherwise it's going to be a case of implementing the logic in your own code

if ($worksheet->getCell('A1)->getValue() === 'foo') {
    $worksheet->setCellValue('B1', 'bar');
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by oleibman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants