daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest May 17th, 2018 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. wb = xlsx_package.workbook
  2.  
  3. wb.styles do |style|
  4.   project_heading = style.add_style(b: true, sz: 14)
  5.   heading = style.add_style(b: true)
  6.  
  7.   wb.add_worksheet(name: "Items") do |sheet|
  8.     # Add a title row
  9.     sheet.add_row ["Inventory Items"], style: project_heading
  10.     # Add the date this was downloaded
  11.     sheet.add_row ["Downloaded at", Time.now.strftime("%b %-d, %Y")]
  12.     # Add a blank row
  13.     sheet.add_row []
  14.     # Create the header row
  15.     sheet.add_row ["ID", "Item Name", "Quantity"], style: heading
  16.     # Create the database reference row
  17.     sheet.add_row ["id", "name", "quantity"], style: heading
  18.     # Create entries for each item
  19.     @items.each do |item|
  20.       sheet.add_row [item.id, item.name, item.quantity]
  21.     end
  22.   end
  23. end
RAW Paste Data
Top