RubyXL returns HEX Cell code while read a cell

1k Views Asked by At

I am trying read a book with RubyXL, but always return me a Hex code like: #<RubyXL::Cell:0x007f8b597c4390>

workbook = RubyXL::Parser.parse("issues.xlsx")
        worksheet = workbook[0]
        worksheet.extract_data  # Produces a simple rectangular array that consists only of cell values (rather than the Cell objects)
        worksheet = workbook[0]
        #worksheet.sheet_data[0][0] # Returns cell A1 in the worksheet
        logger.info worksheet[17][4]

Is necessary return the string text in the cell?

2

There are 2 best solutions below

0
On BEST ANSWER

What you are doing is getting the actual cell not it's value. To get the cell value, do this:

logger.info worksheet[17][4].value

You might need the cell for other information such as the cell styling:

logger.info worksheet[17][4].font_name
logger.info worksheet[17][4].font_color
logger.info worksheet[17][4].font_size
logger.info worksheet[17][4].border_top
logger.info worksheet[17][4].is_bolded
logger.info worksheet[17][4].is_italicized
logger.info worksheet[17][4].is_struckthrough
logger.info worksheet[17][4].is_underlined
0
On

Add to_a in the end and it will solve your issue.