I need conditional formatting in the sense that if certain conditions are fulfilled the background color should change.
The thing is that the way you've structured your code, it will only happen at spreadsheet generation time, not when the user opens up the spreadsheet and changes the value. If you look at the docs for Spreadsheet::WriteExcel
and search for "condtional formatting", you'll see a more flexible solution. It may or may not work for you depending on what your conditions are, but my guess is that it will.
The only easy day was yesterday