3

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)
diegoesp
  • 113
  • 1
  • 10
  • Welcome to the community. Can you share a sample list of code of what you have already tried? – Phlume Apr 30 '15 at 01:04
  • roo does not have implemented reader for background color – Aguardientico Apr 30 '15 at 01:16
  • Damn. You seem to know more about this than I do :) Any suggestions on how to proceed? Any "advanced" parsing feature that I could use with roo, like a method call to return raw cell information that I could parse? – diegoesp Apr 30 '15 at 01:22

1 Answers1

3

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
diegoesp
  • 113
  • 1
  • 10