1

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?

4

2 回答 2

2

你正在做的是得到实际的细胞而不是它的价值。要获取单元格值,请执行以下操作:

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

您可能需要单元格来获取其他信息,例如单元格样式:

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
于 2014-10-23T19:34:06.847 回答
0

最后添加 to_a ,它将解决您的问题。

于 2014-07-07T07:26:01.920 回答