How to persist Excel References in formulas across worksheets where the worksheet is blank?

折月煮酒 提交于 2019-12-11 09:56:15

问题


Is it possible in Excel to create a template with formula to other named empty sheets such that the references to the cells always remain and don't end up like this?

='Data'!#REF!

I am using python, pandas and openpyxl to populate multiple named worksheets with various pandas dataframes. The 1st, 2nd and 3rd sheets are templates with references to the other worksheets.

Why is this required : If I have data in the template of say 10 rows and write a dataframe of 5 rows the remaining 5 existing rows remain.

It might be possible to clear the target sheet before the to_excel but I think this may force the links to break.

I've looked at this How to preserve a formula's reference to a worksheet when the worksheet is deleted and replaced? but it seems quite tedious to have to create another indirect reference.


回答1:


This was solved using Named Ranges.



来源:https://stackoverflow.com/questions/35604888/how-to-persist-excel-references-in-formulas-across-worksheets-where-the-workshee

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!