0

I'm trying to replicate excel formula in python using openpyxl.

Here, get_column_letter(n) is used to point to the relevant column.

date column contains data in this "2021-08-18 00:00:00" format.

from openpyxl import Workbook, load_workbook
from openpyxl.utils import get_column_letter

wb = load_workbook('Result.xlsx')
ws = wb.active

date = get_column_letter(3)
week = get_column_letter(11)
weekStart = get_column_letter(12)
weekEnd = get_column_letter(13)
weekName = get_column_letter(14)

for col in range(2, len(ws[date])+1):
    ws[week + str(col)] = f"= WEEKNUM({date + str(col)})"

for col in range(2, len(ws[date])+1):
    ws[weekStart + str(col)] = f"= MINIFS({date}:{date},{week}:{week},{week + str(col)})"

This is the excel output I get when I run the script Excel output

Here in this image Excel Formula you can see that an "@" is being appended by default to it. Any idea why this occurs and how to resolve it would be highly appreciated. Thanks.

balderman
  • 21,028
  • 6
  • 30
  • 43
Neil
  • 3
  • 2
  • The @ sign means that your Excel is capable of dynamic array formulas but is preventing that (ie: no formula spill). I've never tried it, I'm on an older Excel version but it seems like OpenPyxl has a [worksheet formula attributes property](https://stackoverflow.com/questions/57298554/how-to-insert-array-formula-in-an-excel-sheet-with-openpyxl). – Warcupine Sep 23 '21 at 13:58

0 Answers0