ruby 电子表格行背景颜色 [英] ruby spreadsheet row background color
本文介绍了ruby 电子表格行背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用电子表格"解析 Excel 电子表格.如何获取每一行的背景颜色?
I am trying to parse an excel spreadsheet using "spreadsheet". How could I get the background color of each row?
推荐答案
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet :name => 'Name'
format = Spreadsheet::Format.new :color=> :blue, :pattern_fg_color => :yellow, :pattern => 1
sheet.row(0).set_format(0, format) #for first cell in first row
或
sheet.row(0).default_format = format #for entire first row
您可以遍历每一行/单元格并在您想要的位置准确应用样式
you can iterate over each row/cell and apply style exactly where you want
这篇关于ruby 电子表格行背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文