使用 AXLSX GEM 如何在横向方向上生成 Excel



我在轨道中使用axlsx宝石,需要在横向方向上生成 excel

wb = xlsx_package.workbook
wb.add_worksheet(name: "Semestre") do |sheet|
sheet.add_row ["Período", "Turma", "Sala", "Disciplina", "Tipo", "Híbrida", "Dia da Semana", "Hora Inicial", "Hora Final", "CH", "Curso", "Professor", "Matrícula"]
@oferta.each do |oferta|
if oferta.sala_id != nil 
sala=oferta.sala.nome 
else 
sala="-" 
end
sheet.add_row [oferta.periodo, oferta.codturma, sala, oferta.disciplinaturma.disciplina.nome, oferta.tipoaula, oferta.disciplinaturma.disciplina.hibrida, oferta.diasemana, oferta.horainicial.try(:strftime, ("%H:%M")), oferta.horafinal.try(:strftime, ("%H:%M")), oferta.cargahoraria.to_s+" h", oferta.disciplinaturma.turma.curso.nome, oferta.professor.nome, oferta.professor.matricula]

结束 结束

您是否检查过此文档

wb = Axlsx::P ackage.new.workbook

创建工作表时使用选项。

ws = wb.add_worksheet :p age_setup => {:fit_to_width => 2, :方向 => :landscape}

此文档还可以帮助您

最新更新