Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

when '#,##0.00;[Red](#,##0.00)' then number_format('%.2f', '[Red](%.2f)')
# FIXME: not quite sure what the format should look like in this case.
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