rubyroo-gem

Roo gem: cell background color


I'm using the Roo ruby gem to parse an xlsx file.

Is there any way to get the background color of a cell? I've looked all around the code but couldn't find how to do it.

Opening a spreadsheet using roo is very straightforward:

spreadsheet = Roo::Excelx.new(file_path)
# Get me a sheet
sheet = spreadsheet.sheet("278")
# I happily thought excelx_format would return something that has
# to do with color, but it (sensibly) returns the cell format.
# In this case is GENERAL (no particular format)
puts sheet.excelx_format(6, 6)

Solution

  • I looked around a little more and Roo does not seem to provide any advanced functions for custom inspection.

    So I switched gems. I'm using spreadsheet now.

    spreadsheet = Spreadsheet.open(file_path)
    sheet = spreadsheet.worksheet("278")
    row = sheet.row(5)
    background_color = row.format(5).pattern_bg_color