wb = xlsx_package.workbook
wb.styles do |s|
wrap_text = s.add_style :alignment => { :horizontal => :center,
:vertical => :center ,
:wrap_text => true}
wb.add_worksheet(name: "feedbacks") do |sheet|
sheet.add_row ["商品评价数据"], :style=>wrap_text
sheet.add_row ["订单编号", "客户姓名", "手机号", "评价内容", "回复内容", "评价时间"], :style=>wrap_text
@sdj_evaluates.find_each do |evaluate|
sheet.add_row [evaluate.order_no, evaluate.try(:customer).try(:name), evaluate.phone, evaluate.content, evaluate.reply, evaluate.evaluate_created_at.strftime('%Y-%m-%d %H:%M:%S')], :style=>wrap_text
end
end
end
上述代码中的 order_no 是订单编号,可是数据太长,如下图所示: