Thread Rating:
  • 318 Vote(s) - 2.84 Average
  • 1
  • 2
  • 3
  • 4
  • 5
円貨と外貨の桁を合わせたい
10-30-2013, 03:56 PM,
#2
RE: 円貨と外貨の桁を合わせたい
エクセルだと、小数点以下を0で埋めるか、整数の場合にも小数点が表示される方法しかなかったのですが、
http://www.relief.jp/itnote/archives/000418.php

Curl であれば、下記のような方法で実現できそうですね。
パディングの処理は、ゼロ埋めなどにも使えそうです。

フォントが等幅フォントである必要がありますが。


Code:
||空白をパディングする
{define-proc public {padding str:String, length:int, padding-char:char = ' '}:String
    let ret:String = str
    def padding-amount = length - ret.size
    {if padding-amount > 0 then
        set ret = ret & {String.repeat-char padding-char, padding-amount}
    }
    {return ret}

}

||少数桁位置を合わせる
{define-proc public {alignment str:String, digit-size:int}:String
    let ret-val:String = ""
    def str-ary:StringArray = {str.split split-chars = '.'}
    {switch str-ary.size
    case 1 do
        set ret-val = str & {padding "", digit-size + 1}
    case 2 do
        set ret-val = str-ary[0] & "." & {padding str-ary[1], digit-size}
    else
        {return str}
    }
    {return ret-val}
}


{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField "amount", domain = String}
        },
        {RecordData amount = "12345.6789"},
        {RecordData amount = "123"},
        {RecordData amount = "1.0000"},
        {RecordData amount = "1.00"},
        {RecordData amount = "1.20"},
        {RecordData amount = "1.2"}
    }
}
{value
    {RecordGrid
        font-family = "MS ゴシック",
        font-size = 10pt,
        record-source = people,
        {RecordGridColumn
            halign = "right",
            "amount"
        },
        {RecordGridColumn
            "amount",
            halign = "right",
            format-spec =
                {proc {data:any, record:Record}:String
                    {return {alignment data asa String,  4}}
                }
        }
    }
}


Messages In This Thread
RE: 円貨と外貨の桁を合わせたい - by umemura - 10-30-2013, 03:56 PM
Forum Jump:


Users browsing this thread:
2 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('998')