Python Forum
Help using a dynamic array excel formula with XLWings
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help using a dynamic array excel formula with XLWings
#2
When assigning the formula using xlwings in your code, the formula is being placed between curly braces {} because it is an array formula. To avoid this, you need to use the .formula property instead of .formula_array to assign the formula to the cell. Here's an updated version of your code:

# ...
# Load workbook
wb = xw.Book(output_file_path)

# Get the sheet
sheet = wb.sheets['RESULTS-ExcelVersion']

# Assign the formula to cell A9
sheet.range('A9').formula = '=IFERROR(SORT(FILTER(\'Fwd Data\'!B:P,\'Fwd Data\'!A:A=TRUE),2,-1),"NO RESULTS FOUND WITHIN THESE THRESHOLDS")'

# Save and close the workbook
wb.save()
wb.close()
# ...

By using .formula instead of .formula_array, the formula will be assigned correctly without the curly braces.
Larz60+ write Jun-06-2023, 11:35 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
RE: Help using a dynamic array excel formula with XLWings - by rajeshgk - Jun-06-2023, 05:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  multithreading xlwings error Equivocal 0 360 Jan-25-2025, 05:10 PM
Last Post: Equivocal
  xlwings error when reading a workbook Mishal0488 1 2,310 Aug-01-2023, 02:05 AM
Last Post: deanhystad
  Openpyxl manipulate excel write formula SamLiu 0 2,205 Nov-04-2022, 03:00 PM
Last Post: SamLiu
  {SOLVED]Help getting formula value in Excel to a csv Pedroski55 1 3,002 Sep-20-2021, 12:19 AM
Last Post: Pedroski55
  Python “Formula” Package: How do I parse Excel formula with a range of cells? JaneTan 1 3,550 Jul-12-2021, 11:09 AM
Last Post: jefsummers
  How do I read in a Formula in Excel and convert it to do the computation in Python? JaneTan 2 3,659 Jul-07-2021, 02:06 PM
Last Post: Marbelous
  Reading from Excel: value not formula! faryad13 0 3,076 Oct-28-2020, 09:52 PM
Last Post: faryad13
  Openpyxl: Excel formula & condition formatting removed JaneTan 0 5,091 Sep-25-2020, 07:02 AM
Last Post: JaneTan
  xlwings UDF showing name error pwt 9 7,163 May-29-2020, 07:09 AM
Last Post: pwt
  Want to add formula to excel sheet nagu4651 1 3,054 Dec-26-2019, 10:13 PM
Last Post: keuninkske

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020