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

Support formatting excel currencies #557

Merged
merged 9 commits into from
Mar 19, 2022

Conversation

bmidgley
Copy link

@bmidgley bmidgley commented Mar 11, 2021

Summary

Can formatted currencies include the currency symbol? This PR adds Roo support for calling format on a currency-formatted cell and getting a value with the currency symbol back.

Other Information

There is a simple format for US currencies and a more complex form for others. Anything that's not a US currency appears to shift the format entirely from "Currency" to "Accounting".

The accounting format appears to be multiple functions which probably need a new library to fully execute. What I do instead is look for a pattern in the first function that appears to identify the currency symbol and digital formatting.

The sample I got for applying Euro formatting is:

([$€-2]\ * #,##0.00);([$€-2]\ * (#,##0.00);([$€-2]\ * "-"??);(@_)

And I just used the first part and extracted the currency symbol and format there.

@@ -66,6 +66,16 @@ def generate_formatter(format)
when '##0.0E+0' then '%.1E'
when "_-* #,##0.00\\ _€_-;\\-* #,##0.00\\ _€_-;_-* \"-\"??\\ _€_-;_-@_-" then number_format('%.2f', '-%.2f')
Copy link
Author

@bmidgley bmidgley Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expression is similar but it isn't defended with a spec so I can't tell if I could handle it too. It also appears to discard the €--we expect to have it in the formatted value.

@bmidgley
Copy link
Author

@simonoff is this something you can review for merge? We are using it in prod and it's working out fine.

@simonoff simonoff merged commit 3ae128f into roo-rb:master Mar 19, 2022
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

Successfully merging this pull request may close these issues.

2 participants