axlsx

Create an excel in delayed job method using axlsx

耗尽温柔 提交于 2019-12-01 13:39:00
I am trying to generate an excel file in my delayed job method in model. which is working fine in local. i'm using scheduler to run delayed jobs in heroku. Jobs are getting finished successfully without generating excel. my delayed job method looks like: def self.generate_excel Axlsx::Package.new do |p| p.workbook.add_worksheet(:name => "Stock Details") do |sheet| sheet.add_row ["S.No", "ProductId", "Title"] products.each_with_index do |prods, index| sheet.add_row ["1", "1234", "product title"] end end p.serialize("#{Rails.root}/app/views/stock_details/stock_details.xlsx") end I'm using

Create an excel in delayed job method using axlsx

耗尽温柔 提交于 2019-12-01 12:02:07
问题 I am trying to generate an excel file in my delayed job method in model. which is working fine in local. i'm using scheduler to run delayed jobs in heroku. Jobs are getting finished successfully without generating excel. my delayed job method looks like: def self.generate_excel Axlsx::Package.new do |p| p.workbook.add_worksheet(:name => "Stock Details") do |sheet| sheet.add_row ["S.No", "ProductId", "Title"] products.each_with_index do |prods, index| sheet.add_row ["1", "1234", "product title

AXLSX merge cells inside a style

雨燕双飞 提交于 2019-12-01 09:27:04
I'm using ruby gem axlsx and want to know if there's a way to set merge columns inside a style? Today i doing like this: sheet.merge_cells "A1:E1" sheet.add_row [I18n.t('foo.some_label').upcase], style: [title] sheet.merge_cells "B2:E2" ... I want to avoid to increment the cells manually (B2:E2...B5:E5), there's a way to do this? Yes give this a try (*Disclaimer I did not actually test these methods but I have used similar functionality in the past) def merge_last_row(sheet,options ={}) last_row = sheet.rows.last.index + 1 first_col,last_col = options[:columns] if first_col && last_col sheet

AXLSX merge cells inside a style

早过忘川 提交于 2019-12-01 07:05:29
问题 I'm using ruby gem axlsx and want to know if there's a way to set merge columns inside a style? Today i doing like this: sheet.merge_cells "A1:E1" sheet.add_row [I18n.t('foo.some_label').upcase], style: [title] sheet.merge_cells "B2:E2" ... I want to avoid to increment the cells manually (B2:E2...B5:E5), there's a way to do this? 回答1: Yes give this a try (*Disclaimer I did not actually test these methods but I have used similar functionality in the past) def merge_last_row(sheet,options ={})

Formatting a cell as Text using the axlsx spreadsheet ruby gem?

血红的双手。 提交于 2019-11-30 23:23:43
问题 I'm using the axlsx ruby gem to create Excel-compatible .xlsx files. I can't figure out how to override the cell type that is generated by it's automatic type detection. For Active Record model attributes of type string the gem is setting the Excel cell format to General, but I want it to use Text explicitly. That way I can avoid stripping leading zeros off of zip codes, etc. Anybody know how to accomplish this? 回答1: You can override the type of data using the types option on add row.