Closed gremito closed 5 years ago
Did you read the documentation for 3.4.0? Especially "Convenience methods" section?
@weshatheleopard I am looking at the document of 3.4.2. The source code is the same version.
@gremito Namely:
Starting with version 3.4.0, the main data structure has been separated from the convenience methods that provide access to individual features of the xlsx format, in order to decrease the memory footprint. If you intend to use these features, you will need to additionally include the respective files:
require 'rubyXL/convenience_methods/cell' require 'rubyXL/convenience_methods/color' require 'rubyXL/convenience_methods/font' require 'rubyXL/convenience_methods/workbook' require 'rubyXL/convenience_methods/worksheet'
If you do not care about your RAM usage, just include them all at once by adding the following line to your code so it can continue operating just as before:
require 'rubyXL/convenience_methods'
@weshatheleopard Ohh I see! Was it convenience-methods on the README.
I applied it again and confirmed it.
Code:
desc "add_cell"
task :add_cell do
$:.unshift File.dirname(__FILE__) + '/lib'
require './lib/rubyXL'
require './lib/rubyXL/convenience_methods/worksheet'
excel_data = RubyXL::Parser.parse(ENV["PATH"])
puts "excel_data[0].sheet_name: #{excel_data[0].sheet_name}"
puts "excel_data[0][0][0].value: #{excel_data[0][0][0].value}"
excel_data[0].insert_column(0)
excel_data[0].add_cell(0, 0, "【Test Data】")
puts "excel_data[0][0][0].value: #{excel_data[0][0][0].value}"
end
Console:
$ bundle exec rake add_cell PATH=/Users/iwamoto_takuya/Desktop/Book1.xlsx
excel_data[0].sheet_name: Sheet1
excel_data[0][0][0].value: type
excel_data[0][0][0].value: 【Test Data】
Thanks!!
The Code(sample) following fails:
Console:
The details of Excel are as follows.
Attach a problematic Excel data to it. Book1.xlsx