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

Help with getting a minimal example to work. #152

Open
yh-tmsk opened this issue Nov 29, 2024 · 2 comments
Open

Help with getting a minimal example to work. #152

yh-tmsk opened this issue Nov 29, 2024 · 2 comments

Comments

@yh-tmsk
Copy link

yh-tmsk commented Nov 29, 2024

Hi all,

This looks like a great package. I have read the doc and I am trying to test it out on a minimal example before I use it on a much larger real world financial model. My objective is to test out when I perturb an input cell, how would the output cell change.

My code:

import formulas

xl = formulas.ExcelModel().from_ranges("'[D:\\misc\\parser_test.xlsx]Sheet1'!B6")

print(
  xl.calculate(
     inputs={"'[parser_test.xlsx]Sheet1'!B4": 4},
     outputs=["'[parser_test.xlsx]Sheet2'!B6"])
)

My sample xlsx file:

parser_test.xlsx

The output I see:

Capture

What I expect to see:

I expect the output to contain the new value for cell B6 after workbook recalculated after changing cell B4 value to 4. So far I only see the input cell new value.

Appreciate the help!

@jonathanhoss
Copy link

Hi @yh-tmsk,

I think you need to capitalise the name of the sheet. I get results with this:

import formulas
x1_model = formulas.ExcelModel().loads("parser_test.xlsx").finish()

sol = x1_model.calculate(
    inputs={
        "'[parser_test.xlsx]SHEET1'!B4": 4
    },

    outputs=[
        "'[parser_test.xlsx]SHEET1'!B6"
    ]
 )
print(sol["'[parser_test.xlsx]SHEET1'!B6"])
# >>> <Ranges>('[parser_test.xlsx]SHEET1'!B6)=[[60.0]]

Hope that helps.

@vinci1it2000
Copy link
Owner

Hi @jonathanhoss,

Thank you for your reply!

The sheet name and range are consistently converted to uppercase because Excel treats them as case-insensitive. To maintain alignment with this behavior, we opted to standardize them in uppercase.

However, the file name is preserved in its original casing since file names are case-sensitive in most operating systems, and changing the case might lead to issues or unexpected behavior.

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

3 participants