References to other cells
See original GitHub issueI am using Python 3.8.5 (Mac OS) and open the resulting xlsx
files with LibreOffice 6.4.5.2
and Apple Numbers 10.1 (6913)
(sorry, I have no MS Excel installed).
I am trying to add formulas that refer to other cells (both cross-sheet and within the same sheet), but they do not work. Here is some code that demonstrates the problem:
#!/usr/bin/env python3
# % locale
# LANG="ru_RU.UTF-8"
# LC_COLLATE="ru_RU.UTF-8"
# LC_CTYPE="ru_RU.UTF-8"
# LC_MESSAGES="ru_RU.UTF-8"
# LC_MONETARY="ru_RU.UTF-8"
# LC_NUMERIC="ru_RU.UTF-8"
# LC_TIME="ru_RU.UTF-8"
# LC_ALL=
# pip install XlsxWriter==1.2.9
import xlsxwriter
wb = xlsxwriter.Workbook('xlsx_bug.xlsx')
sheet1 = wb.add_worksheet("Sheet 1")
sheet2 = wb.add_worksheet("Sheet 2")
sheet2.write(0, 0, 'Cell 2')
sheet1.write_formula(0, 0, "='Sheet 2'.A1")
sheet1.write_formula(1, 0, "='Sheet 2'!A1")
wb.close()
If I higlight the A1
or A2
cell on Sheet 1
and press F4
(it changes a cell reference from absolute to relative), both formulas start to work.
The same could be done on the markup level by changing the following syntax:
<c r="A2"><f>'Sheet 2'!A1</f><v>0</v></c>
to this one:
<c r="A2"><f>'Sheet 2'!A1</f></c>
And this is how the cell looks like when saved by LibreOffice:
<c r="A2" s="0" t="str"><f aca="false">'Sheet 2'!A1</f><v>Cell 2</v></c>
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
Thanks for letting me know. I’ve updated the FAQ with this workaround as well: https://xlsxwriter.readthedocs.io/faq.html
That isn’t an option since it would break compatibility with Excel.
As a alternative you could specify a blank as the result of the calculation. That should force a recalculation in OpenOffice (based on my testing) without needing the “Recalculation on File Load setting”: