roo

How to omit empty rows using last_row in Roo Rails

青春壹個敷衍的年華 提交于 2019-12-24 17:04:28
问题 I have a spreadsheet of members designed as below: My aim is to upload some columns and exclude others. In this case, I wish to upload only the name , age and email and exclude the others. I have been able to achieve this using the slice method as shown below: def load_imported_members spreadsheet = open_spreadsheet spreadsheet.default_sheet = 'Worksheet' header = spreadsheet.row(1) (2..spreadsheet.last_row).map do |i| row = Hash[[header, spreadsheet.row(i)].transpose] member = Member.find_by

How to omit empty rows using last_row in Roo Rails

若如初见. 提交于 2019-12-24 17:03:53
问题 I have a spreadsheet of members designed as below: My aim is to upload some columns and exclude others. In this case, I wish to upload only the name , age and email and exclude the others. I have been able to achieve this using the slice method as shown below: def load_imported_members spreadsheet = open_spreadsheet spreadsheet.default_sheet = 'Worksheet' header = spreadsheet.row(1) (2..spreadsheet.last_row).map do |i| row = Hash[[header, spreadsheet.row(i)].transpose] member = Member.find_by

Validation of uploaded Excel file before save using Rails with Roo-xls gem

痞子三分冷 提交于 2019-12-13 17:11:02
问题 In a model, before uploading an .xls file, I want to be able to validate excel files before they are saved by the application. I am trying to open the to-be-saved excel file from the :file_url object(column in comits table where the .xls files will be saved) and then validate it but I am getting a no implicit conversion of Symbol into String error. The validation works when I place the actual file path of an excel file that has been uploaded and saved by carrierwave into Roo::Excel.new("")

undefined method `fetch_value' for nil:NilClass when using Roo

我们两清 提交于 2019-11-28 13:52:00
I am trying to use Roo to import data from an Excel spreadsheet into a table (data_points) in a Rails app. I am getting the error: undefined method `fetch_value' for nil:NilClass and that error references my data_point.rb file at line (see below for full code excerpt): data_point.save! The "Application Trace" says: app/models/data_point.rb:29:in `block in import' app/models/data_point.rb:19:in `import' app/controllers/data_points_controller.rb:65:in `import' I am puzzled by this because a "find all" in my entire app shows no instance of fetch_value Here is the other code in my app: In my model

undefined method `fetch_value' for nil:NilClass when using Roo

岁酱吖の 提交于 2019-11-27 07:58:59
问题 I am trying to use Roo to import data from an Excel spreadsheet into a table (data_points) in a Rails app. I am getting the error: undefined method `fetch_value' for nil:NilClass and that error references my data_point.rb file at line (see below for full code excerpt): data_point.save! The "Application Trace" says: app/models/data_point.rb:29:in `block in import' app/models/data_point.rb:19:in `import' app/controllers/data_points_controller.rb:65:in `import' I am puzzled by this because a