Write Formulas in Excel through Python XlsWriter

Writing formulas with Excel with Python is a technique, that needs some practice, actually. Although XlsWriter has some good documentaion, not a lot is covered on the point, that concerns creating a file with a formula in it. First and probably most important point – formulas should be written in string in English, completely ignoring the local Excel language. Something like .Formula  in VBA, actually.

Thus, the code below produces the scraped links from vitoshacademy.com into column A and their length, calculated by the formula =LEN(A1) in column B:

The result looks like this:

Above, it is quite interesting, that the worksheet is automatically named “Sheet1” and not the default for Germany – “Blatt1”, although the formulas are the standard German ones.

Tagged with: , , , ,