Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculation fails on dates #140

Open
emilzak opened this issue Apr 18, 2024 · 0 comments
Open

Calculation fails on dates #140

emilzak opened this issue Apr 18, 2024 · 0 comments

Comments

@emilzak
Copy link

emilzak commented Apr 18, 2024

The problem
I created two user-defined functions, BSDATE and BSNUMBER. BSDATE returns datetime.date and BSNUMBER returns int.
Operations performed on numbers work well. Ops on dates fail with #VALUE!

I've attached the excel and python code.

Please look at D1 (Error) and D2 ( Success )

import datetime
import formulas

def _BSDATE(m):
	return datetime.date(2024,m,30)
def _BSNUMBER(n):
	return n

FUNCTIONS = formulas.get_functions()
FUNCTIONS["BSDATE"] = _BSDATE
FUNCTIONS["BSNUMBER"] = _BSNUMBER

xl_model = formulas.ExcelModel().loads("333.xlsx").finish()
xl_model.calculate()
xl_model.write(dirpath="output")

Python: 3.8
OS: macOS Sonoma

Here is the result of the calculation

image

Please advise, and thanks for your work!

333.xlsx

UPDATE 1:

  1. I tried to return formatted string from _BSDATE function - same result
  2. If i set a string value instead of the function _BSDATE in the excel calculation works correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant