How to format currency columns in Axlsx?

百般思念 提交于 2020-01-04 02:55:10

问题


I am using ruby Axlsx gem for writing my clients accounts data in xlsx. Now I am appending " Dr" string to all debit amounts which is making amount as a string e.g. "1000 Dr". I want to append " Dr" but the amount should still be an integer and excel should give sum at bottom when column is selected.

What I am doing, notice that excel shows sum = 0 in bottom-right even on selecting :-

What I am doing, notice that cell remains a string on selecting (880 Dr should become 880.00 on selecting the cell):-

What I want to do, excel should show sum of selected colums as shown by excel in bottom-right sum=1957.00 Dr:-

What I want to do, the cell should be converted to number when double clicked (1341.00 Dr has become 1341 on selecting)but Dr should be visible on unselecting again:-


回答1:


I solved this by using custom format_code

custom_format = sheet.styles.add_style(:format_code => "#.00  "Dr"")


来源:https://stackoverflow.com/questions/50128473/how-to-format-currency-columns-in-axlsx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!