http://spreadsheet.rubyforge.org“rel=“nofollow noreferer” http://spreadsheet.rubyforge.org,以生成一个电子表格,而Im则有麻烦。 I m 开设现有工作手册并增加数据。
我已要求在一定程度上进行编号格式工作,至少要看到这种数据是数字,但(如非常不重要)客户希望把数字与中心一致:
我目前的法典就是这样:
nfmt = Spreadsheet::Format.new :number_format => 0.00
row = sheet.row(1)
row[0] = "Result"
row[1] = 45.55
row.set_format 1, nfmt
也许没有什么可贵之处,但想知道是否有任何人能够提供帮助?
- Spreadsheet does not modify Formatting at present. That means in particular that if you set the Value of a Cell to a Date, it can only be read as a Date if its Format was set correctly prior to the change.
www.un.org/Depts/DGACM/index_spanish.htm Edit for Trevoke
为此提供帮助。 我曾尝试过你的法典,并做了罚款。 我猜测这一差异是编辑现有的电子表格,在这种情况下,格式被忽略。 为此:
require rubygems
require spreadsheet
Spreadsheet.client_encoding = UTF-8
book = Spreadsheet.open "edit_me.xls" # Blank spreadsheet
sheet1 = book.worksheet 0
format = Spreadsheet::Format.new :horizontal_align => :centre
sheet1.row(0).default_format = format
sheet1.row(0).push I rule 2! , 43.56
book.write edited_you.xls