'Why does my formula from openpyxl require rewrite in LibreOffice?
Sometimes when I write a formula using openpyxl, I get a "#NAME?" error when I open the resulting spreadsheet in LibreOffice. If I go to the cell with the error, add a space to the end of the cell value, and then delete it, the cell computes properly. F9 has no effect, however.
I suspect I'm making a basic mistake. Here's my code.
#!/usr/bin/python3
import openpyxl
output_workbook = openpyxl.Workbook()
output_sheet = output_workbook.active
departments_sheet = output_workbook.create_sheet('departments')
departments_sheet['A1'] = 'CE'
departments_sheet['B1'] = 'foo'
output_sheet['C2'] = 'CE'
output_sheet['B2'] = '=LOOKUP(C2,departments.A:A,departments.B:B)'
output_workbook.save('/tmp/test.xls')
Here's how it looks when I open the result in LibreOffice.

After I add a space to the formula and then delete it, it's fine.

I note that I use uppercase column names in my code and they appear lowercase when the file is loaded. Then they appear uppercase after I rewrite the formula.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
