axlsx
这是一个使用gem创建简单工作簿的测试脚本。我正在尝试遍历行和单元格并将字体颜色更改为红色。但是,只有包含文本的单元格(即本例中的前两行)变为红色。包含数字的行保持默认的黑色。知道如何更改包含数字的单元格的颜色吗?
require 'axlsx'
Axlsx::Package.new do |p|
p.workbook.add_worksheet(:name => "test") do |sheet|
sheet.add_row ["First", "Second", "Third"]
sheet.add_row ["First", "Second", "Third"]
sheet.add_row [1, 2, 3]
sheet.add_row [1, 2, 3]
sheet.add_row [1, 2, 3]
sheet.add_row [1, 2, 3]
sheet.add_row [1, 2, 3]
sheet.rows.each do |x|
x.cells.each do |i|
i.color = "E8000"
end
end
end
p.serialize('test.xlsx')
end