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

Feature Request: Support setting decimal precision values #1757

Open
jc3m opened this issue Dec 14, 2023 · 3 comments
Open

Feature Request: Support setting decimal precision values #1757

jc3m opened this issue Dec 14, 2023 · 3 comments

Comments

@jc3m
Copy link

jc3m commented Dec 14, 2023

Description

I am attempting to use excelize to record some financial data (in US Dollars). This requires using decimal values that have exactly 2 decimal places for cents. Excelize only supports numbers represented as int or float. Upon closer examination of how cell values are set internally, it looks like they are stored as a combination of value (stored as a string), and type. Is there anyway for excelize to support either:

  • Storing decimal precision values natively
  • Setting the value and type directly so that I can serialize decimal precision values to a string, and set the type to a number directly
@xuri
Copy link
Member

xuri commented Dec 15, 2023

Thanks for your issue. This is similar to issues #80 and #189. Excelize library support sets custom Accounting number format or built-in number format for cells.

@jc3m
Copy link
Author

jc3m commented Dec 15, 2023

Thanks for the quick response - unfortunately I don't think formatting alone is sufficient here.

Right now, the only way to set numeric cell values is through using the int or float types directly. Since float is not able to capture decimal (base 10) values exactly, there are potential rounding errors if I try to save exact decimal values with the current API.

For more context, this stack overflow question captures my concerns with trying to use a float and using a number formatter that will just round the value for financial values.

@xuri
Copy link
Member

xuri commented Dec 18, 2023

Could you show us a numeric precision problems case about this? The SetCellDefault function supports storage cell value as numeric by a given string data type value, but if you open the generated workbook, the display cell value is also related to the Excel accuracy limitation.

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

2 participants