有没有办法使用 ruby gem 获取 excel 中单元格的颜色代码?
is there a way to fetch the color code of a cell in excel using a ruby gem?
我正在使用 Ruby 解析 excel 并使用 Roo gem 一段时间,效果很好。现在,我遇到了如何获取单元格颜色的问题,可以吗?
大多数 gem 我发现使用 excel 单元格颜色格式只是为了编写电子表格而不是阅读。
我不认为 Roo gem 有它(好像 an attempt 4 天前有,但没有合并,贡献者关闭了 PR)。
您可以使用 Spreadsheet gem 来获取背景颜色。
# get bg color at 1st Sheet, 3rd row, 5th column.
# I didn't run this.. go to gem repository for more accurate examples?
book = Spreadsheet.open '/path/to/an/excel-file.xls'
sheet = book.worksheet(0)
row = sheet.row(2)
cell_format = row.format(4)
color = cell_format.pattern_bg_color
我正在使用 Ruby 解析 excel 并使用 Roo gem 一段时间,效果很好。现在,我遇到了如何获取单元格颜色的问题,可以吗?
大多数 gem 我发现使用 excel 单元格颜色格式只是为了编写电子表格而不是阅读。
我不认为 Roo gem 有它(好像 an attempt 4 天前有,但没有合并,贡献者关闭了 PR)。
您可以使用 Spreadsheet gem 来获取背景颜色。
# get bg color at 1st Sheet, 3rd row, 5th column.
# I didn't run this.. go to gem repository for more accurate examples?
book = Spreadsheet.open '/path/to/an/excel-file.xls'
sheet = book.worksheet(0)
row = sheet.row(2)
cell_format = row.format(4)
color = cell_format.pattern_bg_color