There was the task of generating an xlsx file with a small report, in which there are charts. Drawing them on the go with the functions of this library seemed to me an irrational solution. So I decided to create a template file in which I created all the necessary diagrams and charts. Selected cells to which they were attached. The calculation was that I programmatically changed the values ​​of these cells and gave them to the site user on the fly.

This scheme seems to work. But there is one trouble. When the user loads the file and opens it, the opening takes place in protected mode, in which these cells for some reason remain the same as they were in the template. And only after I allow editing, the cells change as needed and the diagrams take their proper form.

Is it possible to somehow in a template or programmatically prohibit opening an Excel file in protected mode? Or, maybe, you will prompt some other solutions?

  • @ sergey_pogorelov_93, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

1 answer 1

Protected mode protects the user from macros and other automatically executed potentially harmful code. If any document could turn it off, what would be the point in this mode?

You can generate the data programmatically, but after that, fill in the document on the server side with them and give the user this document ready, without your code running on the user's processor. Then there will be no problems.