wb xlsx_package workbook wb add_worksheet name Outputs do sheet sheet

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
wb = xlsx_package.workbook
wb.add_worksheet(name: 'Outputs') do |sheet|
sheet.add_row ["Дата", "ФИО", "Ставка", "Продукция", "Выработка станка", "Время", "Выработка", "План", "Процент", "Зарплата"]
@outputs.each do |output|
output.output_products.each.with_index do |output_product, index|
sheet.add_row [
(index==0) ? output.date : "",
(index==0) ? output.employee.fio : "",
(index==0) ? output.employee.base_pay : "",
output_product.product.title, output_product.product.machine_output.prod,
output_product.work_time,
output_product.output_amount,
plan = output_product.product.machine_output.production / 12 * output_product.work_time,
output_product.output_amount * 100 / plan,
(index==0) ? output.salary : ""]
end
end
end