Created
January 18, 2018 10:35
-
-
Save Kalaivanimurugan/b21610b049796b6557f61ee4239411c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wb = xlsx_package.workbook #create excel book | |
wb.add_worksheet(name: "Stock Status") do |sheet| | |
sps_img = File.expand_path(Rails.root+'app/assets/images/sps_logo.png') | |
sheet.add_image(:image_src => sps_img, :end_at => true) do |image| | |
image.start_at 0, 0 | |
image.end_at 3, 4 | |
end | |
header = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}, :border => { :style => :thin, :color => "000000" }}) | |
border = wb.styles.add_style({:border => { :style => :thin, :color => "000000" }}) | |
align_right = wb.styles.add_style({:alignment => {:horizontal => :right}}) | |
align_left = wb.styles.add_style({:alignment => {:horizontal => :left}}) | |
sheet.add_row ["Product Replenishment ", "report based on #{@reporting_date}"] | |
sheet.add_row | |
sheet.add_row ["Input Criteria"] | |
sheet.add_row ["Date : ", @reporting_date], :style => [align_right, align_left] | |
sheet.add_row ["Product Code", "Product Description", "UOM"] + @all_vm_names + ["Total Stock Qty"], :style => header | |
@final_data.flatten.each do |datum| | |
product = get_product_detail(datum[:product_code]) | |
vm_based_arr = [] | |
total = 0 | |
datum[:vm_based_products].each do | k, v | | |
total += v | |
vm_based_arr.push(v) | |
end | |
sheet.add_row [product.code, product.description, product.uom] + vm_based_arr + [total], :style => border | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment