Barak Rosenfeld
Barak Rosenfeld

Reputation: 394

How can I create a formula using xlsx writer

Hi I am creating an xlsx file using xlsxwriter is there a way to create an excel formula using this object?

Upvotes: 0

Views: 2397

Answers (1)

grovesNL
grovesNL

Reputation: 6075

You can write an Excel formula just as you would write a value.

For example:

import xlsxwriter
workbook = xlsxwriter.Workbook('sample.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 2)
worksheet.write('B1', '=A1*4')
workbook.close()

Now the spreadsheet cell A1 has a value of 2, and cell B1 uses the formula =A1*4 (which is 8).

Upvotes: 3

Related Questions