# Maintaining Formulas when Writing Data to Excel

**URL:** <https://forum.knime.com/t/maintaining-formulas-when-writing-data-to-excel/47023>\
**Category:** KNIME Analytics Platform\
**Created:** [September 12, 2022, 7:55pm UTC](https://forum.knime.com/t/maintaining-formulas-when-writing-data-to-excel/47023 "2022-09-12T19:55:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CKillick](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@CKillick](https://forum.knime.com/u/CKillick)\
**Post date:** [September 12, 2022, 7:55pm UTC](https://forum.knime.com/t/maintaining-formulas-when-writing-data-to-excel/47023/1 "2022-09-12T19:55:40Z")

</div>

Hello Everyone

I’m hoping I can once again gather the wisdom of the community for an issue I’m having with writing data to excel. I’ve searched the forums for a solution but was unable to find one. So if I’ve missed it, please redirect me.

I’m building a workflow that produces many individual excel reports based on a large excel ‘masterlist’. The data manipulation element is working well. What I need to do now is write the individual reports to pre-existing excel templates. What I’ve done is ensured that the excel templates ‘end’ in the correct place, and then use the ‘Write to Excel’ node and append the data to them. From that point I use conditional formatting rules to make sure everything is looking spiffy.

The problem is that the templates contain a few simple formulas to count the data and produce basic analytics. And even though the data is written to the excel document, within the range that they cover, the values do not update when the excel documents are opened. I have to do something like delete and replace a row, to make them read anything other than 0. I’ve attached a screenshot below.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/4/e/4ea9a07d686a540bd23ba02d8b74abedd2a4b046.png)

Does anyone have any idea how I can get excel to automatically update these formulas when I write the data to excel? If not, is there a way that I can run equivalent operations in knime and write them into the template along with the rest of the info? Unfortunately I’m stuck with these templates, so any solution I come up with need to look the same at the end.

Hope that makes sense, thank you so much in advance.  
Cam

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [September 12, 2022, 9:08pm UTC](https://forum.knime.com/t/maintaining-formulas-when-writing-data-to-excel/47023/2 "2022-09-12T21:08:56Z")

</div>

@CKillick there is this thread about Excel and keeping formats etc. when writing new data:

> [@Writer Node Issues](https://forum.knime.com/t/writer-node-issues/44776/2):
>
> @helpmeplease if you want the structure of your Excel file unchanged and just change values there are these options, if you must change data on a pre-formatted sheet (otherwise you might just replace this sheet). The Excel Cell Updater can change values in specific cells. You can use a community node to write to an Excel file without changing the structure or formats: You can the use [Python](https://kni.me/w/AvjrddXKOIoZYLV3) and [OpenPyxl](https://hub.knime.com/search?q=openpyxl&type=Workflow&tag=openpyxl,excel&sort=best) to do more complex editings of excel files. You will have to plan ahead what this d…

Th node [Write To Excel Template (deprecated) – KNIME Community Hub](https://kni.me/n/y7AwntQqYbCQA6cq) can be used to recalculate formulas on the same page. I also toyed around with openpyxl to refresh the formula results but it is not exactly what I was hoping for.

> [@Excel-Reader and Excel-Writer reevaluate](https://forum.knime.com/t/excel-reader-and-excel-writer-reevaluate/38380/2):
>
> @ingo_knime not sure if this is related but there was a thread about formulas and evaluation and there also is a ticket for a bug (AP-17559) - @ScottF . I experimented with [openpyxl](https://hub.knime.com/search?tag=openpyxl&type=Workflow) and the [AF nodes](https://hub.knime.com/search?tag=ExcelUtil) - "[Write to Excel Template](https://hub.knime.com/anotherfrauduser/extensions/org.anotherfraud.excel.feature/latest/org.AF.ExcelUtilities.WriteToExcelTemplate.WriteToExcelTemplateXLSXNodeFactory)"also offers a re-calculation but again only of the sheet that has been filled it seems. But could not find a workaround.

Another option could be to delete and re-write the formula thru [openpyxl](https://hub.knime.com/search?tag=openpyxl&type=Workflow) and see if that would cause a recalculation.

Some time back Excel itself had problems with some recalculations on large files. I remember sending manual keystrokes thru VBA in order to force a full recalculation (not very elegant indeed). I am not sure if this is still a thing with Excel itself and how this might affect other software interacting with Excel.

---

<div class="post-metadata">

**Author:** ![CKillick](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@CKillick](https://forum.knime.com/u/CKillick)\
**Post date:** [September 13, 2022, 5:16pm UTC](https://forum.knime.com/t/maintaining-formulas-when-writing-data-to-excel/47023/3 "2022-09-13T17:16:58Z")

</div>

Thanks very much @mlauber71, I’ll definitely take a look at those. If anyone else has some advice or any other potential solutions I’d love to hear them as well.

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [December 12, 2022, 5:17pm UTC](https://forum.knime.com/t/maintaining-formulas-when-writing-data-to-excel/47023/4 "2022-12-12T17:17:34Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
