ruby spreadsheet row background color

前端 未结 3 880
粉色の甜心
粉色の甜心 2021-01-18 09:53

I am trying to parse an excel spreadsheet using \"spreadsheet\". How could I get the background color of each row?

3条回答
  •  -上瘾入骨i
    2021-01-18 10:18

    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
    

    or

    sheet.row(0).default_format = format #for entire first row
    

    you can iterate over each row/cell and apply style exactly where you want

提交回复
热议问题