Commit fac6e334 by liyijie

feat: 更新支持xls格式

parent 3c1be135
...@@ -2,6 +2,7 @@ module TalltyImportExport ...@@ -2,6 +2,7 @@ module TalltyImportExport
class Excel class Excel
require 'redis-objects' require 'redis-objects'
require 'roo' require 'roo'
require 'roo-xls'
attr_reader :uid, :cache attr_reader :uid, :cache
......
module TalltyImportExport module TalltyImportExport
class Import class Import
require 'roo' require 'roo'
require 'roo-xls'
attr_reader :klass, :context, :primary_keys, :associations attr_reader :klass, :context, :primary_keys, :associations
def initialize klass def initialize klass
...@@ -53,7 +54,7 @@ module TalltyImportExport ...@@ -53,7 +54,7 @@ module TalltyImportExport
end end
else else
file_path = xlsx_file.is_a?(String) ? xlsx_file : xlsx_file.path file_path = xlsx_file.is_a?(String) ? xlsx_file : xlsx_file.path
xlsx = ::Roo::Excelx.new(file_path) xlsx = ::Roo::Spreadsheet.open(file_path, extension: File.extname(file_path) == '.xls' ? :xls : :xlsx)
xlsx.each_with_pagename do |_sheetname, sheet| xlsx.each_with_pagename do |_sheetname, sheet|
sheet.each(**@excel_hash).with_index do |line_info, index| sheet.each(**@excel_hash).with_index do |line_info, index|
next if index == 0 next if index == 0
......
module TalltyImportExport module TalltyImportExport
VERSION = "1.0.35" VERSION = "1.1.1"
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment