My script reads a xls file, modifies two columns and writes it back to disc.
The file has 7 columns, two of which are numbers, the others text. When I view the result at the end of the process, the contents (sheet) are correct. However, after writing to disc, only the number columns are written, the text columns are blank.
Any suggestions of how to solve this? Using gem version 1.14
Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet.open filename sheet=book.worksheet 0 sheet.each_with_index do |row, i| if i>0 row[5]= codes[i-1][0] row[6]= codes[i-1][1] end end out_file= filename.basename.to_s.gsub(/(.*)\.(.*)/,'\1_1.\2') book.write Rails.root.join(Rails.configuration.x.download_dir, out_file).to_s
My script reads a xls file, modifies two columns and writes it back to disc. The file has 7 columns, two of which are numbers, the others text. When I view the result at the end of the process, the contents (sheet) are correct. However, after writing to disc, only the number columns are written, the text columns are blank. Any suggestions of how to solve this? Using gem version 1.14
Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet.open filename sheet=book.worksheet 0 sheet.each_with_index do |row, i| if i>0 row[5]= codes[i-1][0] row[6]= codes[i-1][1] end end out_file= filename.basename.to_s.gsub(/(.*)\.(.*)/,'\1_1.\2') book.write Rails.root.join(Rails.configuration.x.download_dir, out_file).to_s