xlsxwriter: write_array_formula not getting calculated when in another sheet

Viewed 118

My goal is to use write_array_formula and refer to a range of cells in another sheet. I'm trying this code:

workbook = xlsxwriter.Workbook('test.xlsx')

sheet1 = workbook.add_worksheet('Sheet1')
sheet2 = workbook.add_worksheet('Sheet2')

sheet1.write('A1', 'Foo')
sheet1.write('A2', 'Bar')

sheet1.write_array_formula('B1:B2', '{=Sheet1!$A$1:$A$2}')
sheet2.write_array_formula('B1:B2', '{=Sheet1!$A$1:$A$2}')

workbook.close()

With this code I was expecting for column B of Sheet1 and Sheet2 to be identical. But it appears that the formula is not being calculated in Sheet2.

Here's what column B looks like in Sheet 1:

"Foo" in row 1 and "Bar" in row 2

And here's what column B looks like in Sheet 2:

Nothing in row 1 and "0" in row 2

1 Answers

It turns out that this was the result of a bug in XlsxWriter that went unnoticed for a long time.

It is fixed in XlsxWriter version 1.3.1 and later. Thanks.

Related