I've an excel workbook with multiple columns which have dates as the column name. Is there a way to apply formulas to each column in openxlsx. I need a way to dynamically populate each column with the appropriate excel formula as the no of columns is huge.
This is sheet 1. Please Note: The letter at the top of the columns names signify the excel column names and the numbers at the start of each row are the excel row numbers.
A B C D
Product 1/1/2020 1/1/2019 1/1/2018
1 1 1 10 1
2 2 2 20 1
3 3 3 30 10
4 4 2 10 5
5 5 4 5 10
This is sheet 2
A B C D E
Product Skill 1/1/2020 1/1/2019 1/1/2018
1 1 W2 1 1 10
2 2 W45 20 1 0
3 3 W0 40 5 0
4 4 W1 50 5 1
5 5 W2 2 2 1
This is the resultant sheet. The excel formula for cell C1 "='Sheet1'!B1*'Sheet2'!C1"
The excel formula for cell D1 "='Sheet1'!C1*'Sheet2'!D1"
The excel formula for cell E1 "='Sheet1'!D1*'Sheet2'!E1"
A B C D E
Product Skill 1/1/2020 1/1/2019 1/1/2018
1 1 W2 1 10 10
2 2 W45 40 20 0
3 3 W0 120 150 0
4 4 W1 100 50 5
5 5 W2 8 10 10
As I'm new to openxlsx is there a way to do this using the write_formula function. I want to automate the process as the number of columns is very large. Thanks.