Openpyxl - Adding Formulas to Excel Workbooks with Python | Data Automation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video will review how to add formulas to an Excel worksheet using the python Library open Pi Excel in this testing document I have 10 rows of random numbers in column A I will be adding these numbers using the sum function counting these numbers using the count function and averaging them using the average function all placed in column B here I am bringing in my workbook as WB and assigning the worksheet WS I will then be saving my work in the cell below it adding formulas to cells is very easy to do with openpixel all you have to do is pass the Excel formula as a string of text to the desired cell you want that formula to exist in I have a number of formulas already written out let me bring them over to the cell right here so working down the B column next to my data I will be including the sum average and count of the first 10 rows in column A where the data resides as you can see these are just the formulas as you would see them in the Excel formula bar or in the cell itself the only difference is I'm surrounding these formulas with a string so let's execute this code I will then reopen the workbook and we will see what happens and there you go we now have the sum the average and the count of the desired calculated area you can see A1 through A10 we can also confirm that this is accurate by looking down here the sum is 62. the average is 6.2 and the count is 10 representing the 10 rows of data in this column so it is actually quite easy to add formulas to an Excel workbook using this Library all you need to do is pass the formula to the cell you want to place them in making sure that the formulas are passed as a string thank you for watching please leave a comment below letting me know if this was a helpful video and be sure to subscribe so that you know when the next video drops
Info
Channel: Data Automation
Views: 1,091
Rating: undefined out of 5
Keywords: Descript
Id: 793om3TWmsk
Channel Id: undefined
Length: 2min 20sec (140 seconds)
Published: Fri Apr 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.