advisr-io / excel4node

Node module to allow for easy Excel file creation
MIT License
124 stars 18 forks source link

Formula value blank in "Protected View" - how to provide initial value? #93

Open wildhart opened 4 months ago

wildhart commented 4 months ago

Describe the bug When a generated Excel file includes formulas, and the file is generated by a website and downloaded, Excel opens the file in "Protected View" and the formula cells are displayed as blank (note that Protected View is NOT activated when files are downloaded from localhost).

Is there a way to provide initial values for the cells which contain formulas?

To Reproduce

  1. Generate a cell which contains a formula, using wc.formula("....")
  2. Upload the code to a webserver (not served from localhost)
  3. Generate and download the file.
  4. Open the file in Excel.

The file looks like this and the formulas are blank:

image

  1. It's necessary to click on "Enable Editing" to display the formula values:

image

Note that I cannot instruct all my webapp users to disable "Protected View".

Expected behavior The result of each formula should be visible even in "Protected View".

Additional context I have tried adding a number to the cell as well as a formula with:

wc.number(100);
wc.formula(....);

And although this increases the size of the generated file, the numbers are not displayed in protected view.

Is there a solution to this?