InnerHTML isn't a very good approach to any problem. You might want to rewrite that stuff using the DOM. You might find that things tend to work better.
At the Build 2018 developer conference that's taking place these days in Seattle, USA, Microsoft announced support for custom JavaScript functions in Excel. What this means is that Excel users will be ...