如何在Axlsx中格式化货币列? [英] How to format currency columns in Axlsx?

查看:65
本文介绍了如何在Axlsx中格式化货币列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ruby Axlsx gem在xlsx中编写我的客户帐户数据.现在我将"Dr"字符串附加到所有借方金额中,这使得金额成为字符串,例如"1000博士".我想附加"Dr",但金额仍应为整数,并且在选择列时excel应该在底部给出总和.

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.

我在做什么,请注意,即使选择:-,excel也显示右下角的sum = 0

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

我在做什么,请注意,单元格在选择时仍然是字符串(880 Dr在选择单元格时应变为880.00):-

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

我想做的是,excel应该显示所选列的总和,如excel在右下角显示的总和= 1957.00 Dr:-

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

我想做的是,双击该单元格应将其转换为数字(1341.00 Dr在选择时已变为1341),但是在再次取消选择时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:-

推荐答案

我通过使用自定义format_code

I solved this by using custom format_code

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

这篇关于如何在Axlsx中格式化货币列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆