エクセルだと、小数点以下を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}}
}
}
}
}